Cogs.Core
IntrusiveList.h
1#pragma once
2
3#include "../FoundationBase.h"
4
5namespace Cogs {
6
7
8 struct COGSFOUNDATION_API IntrusiveNode
9 {
10 IntrusiveNode* next = nullptr;
11 IntrusiveNode* prev = nullptr;
12 };
13
14 struct COGSFOUNDATION_API IntrusiveList
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
23 IntrusiveNode* head;
24 IntrusiveNode* tail;
25 IntrusiveNode* tailPrev;
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
32 IntrusiveList();
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();
39 IntrusiveNode* popBack();
40 IntrusiveNode* back();
41
42 };
43
44}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23