Cogs.Foundation
Loading...
Searching...
No Matches
IntrusiveList.h
Go to the documentation of this file.
1#pragma once
2
3#include "../FoundationBase.h"
4
5namespace Cogs {
6
7
9 {
10 IntrusiveNode* next = nullptr;
11 IntrusiveNode* prev = nullptr;
12 };
13
15 {
16 struct Iterator {
17 IntrusiveNode* ptr = nullptr;
18 bool operator!=(const Iterator& other) const { return ptr != other.ptr; }
19 Iterator& operator++() { ptr = ptr->next; return *this; }
20 IntrusiveNode* operator*() const { return ptr; }
21 };
22
26
27 Iterator begin() { return { head }; }
28 Iterator end() { return { (IntrusiveNode*) & tail }; }
29 //const IntrusiveNode* begin() const { return head; }
30 //const IntrusiveNode* end() const { return (Cogs::Core::IntrusiveNode*) & tail; }
31
33 bool empty() const;
34 void pushFront(IntrusiveNode* node);
35 void pushBack(IntrusiveNode* node);
36 void remove(IntrusiveNode* node);
37 void insert(IntrusiveNode* prev, IntrusiveNode* node);
38 IntrusiveNode* popFront();
40 IntrusiveNode* back();
41
42 };
43
44}
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Main Cogs namespace.
Definition: MortonCode.h:5
Definition: IntrusiveList.h:16
bool operator!=(const Iterator &other) const
Definition: IntrusiveList.h:18
IntrusiveNode * ptr
Definition: IntrusiveList.h:17
Iterator & operator++()
Definition: IntrusiveList.h:19
IntrusiveNode * operator*() const
Definition: IntrusiveList.h:20
Definition: IntrusiveList.h:15
Iterator begin()
Definition: IntrusiveList.h:27
Iterator end()
Definition: IntrusiveList.h:28
IntrusiveNode * popBack()
IntrusiveNode * tailPrev
Definition: IntrusiveList.h:25
IntrusiveNode * tail
Definition: IntrusiveList.h:24
IntrusiveNode * head
Definition: IntrusiveList.h:23
Definition: IntrusiveList.h:9
IntrusiveNode * next
Definition: IntrusiveList.h:10