11 bool isFree() {
return next ==
nullptr && prev ==
nullptr; }
15 template<
typename T,
size_t offset>
23 bool operator!=(
Iterator& other) {
return curr != other.curr; }
24 Iterator& operator++() { curr = next; next = next->next;
return *
this; }
25 T* operator*() {
return get(curr); }
35 assert(head.next !=
nullptr);
36 assert(tail.prev !=
nullptr);
41 return reinterpret_cast<T*
>(
reinterpret_cast<char*
>(n) - offset);
44 void remove(T* item) {
45 assert(myself ==
this);
47 assert(head.next !=
nullptr);
48 assert(tail.prev !=
nullptr);
49 auto* n =
reinterpret_cast<ListNode*
>(
reinterpret_cast<char*
>(item) + offset);
52 assert(n->next->prev == n);
53 assert(n->next->next != n);
56 assert(n->prev->next == n);
57 assert(n->prev->prev != n);
67 assert(head.next !=
nullptr);
68 assert(tail.prev !=
nullptr);
73 assert(myself ==
this);
74 assert(head.next !=
nullptr);
75 assert(tail.prev !=
nullptr);
76 auto* n =
reinterpret_cast<ListNode*
>(
reinterpret_cast<char*
>(item) + offset);
79 assert(n->next ==
nullptr);
80 assert(n->prev ==
nullptr);
81 auto* prev = tail.prev;
87 assert(head.next !=
nullptr);
88 assert(tail.prev !=
nullptr);
94 assert(myself ==
this);
95 assert(head.next !=
nullptr);
96 assert(tail.prev !=
nullptr);
103 head.next->prev = n->prev;
106 assert(head.next !=
nullptr);
107 assert(tail.prev !=
nullptr);
113 assert(myself ==
this);
114 assert(head.next !=
nullptr);
115 assert(tail.prev !=
nullptr);
121 tail.prev->next = n->next;
124 assert(head.next !=
nullptr);
125 assert(tail.prev !=
nullptr);
130 assert(myself ==
this);
131 assert(head.next !=
nullptr);
132 assert(tail.prev !=
nullptr);
133 return head.next == &tail;
136 void swap(List& that)
138 assert(myself ==
this);
139 assert(head.next !=
nullptr);
140 assert(tail.prev !=
nullptr);
141 assert(that.head.next !=
nullptr);
142 assert(that.tail.prev !=
nullptr);
144 auto* thisHeadNext = head.next;
145 auto* thisTailPrev = tail.prev;
146 auto* thatHeadNext = that.head.next;
147 auto* thatTailPrev = that.tail.prev;
149 if (thatHeadNext == &that.tail) {
154 head.next = thatHeadNext;
155 tail.prev = thatTailPrev;
156 thatHeadNext->prev = &head;
157 thatTailPrev->next = &tail;
160 if (thisHeadNext == &tail) {
161 that.head.next = &that.tail;
162 that.tail.prev = &that.head;
165 that.head.next = thisHeadNext;
166 that.tail.prev = thisTailPrev;
167 thisHeadNext->prev = &that.tail;
168 thisTailPrev->next = &that.head;
170 std::swap(count, that.count);
171 assert(head.next !=
nullptr);
172 assert(tail.prev !=
nullptr);
173 assert(that.head.next !=
nullptr);
174 assert(that.tail.prev !=
nullptr);
179 List* myself =
nullptr;
183 assert(myself ==
this);
184 assert(head.next != &tail);
185 assert(head.next !=
nullptr);
186 assert(tail.prev !=
nullptr);
187 return get(head.next);
191 assert(myself ==
this);
192 assert(tail.prev != &head);
193 assert(head.next !=
nullptr);
194 assert(tail.prev !=
nullptr);
195 return get(tail.prev);
198 const T* front()
const {
199 assert(myself ==
this);
200 assert(head.next !=
nullptr);
201 assert(tail.prev !=
nullptr);
202 assert(head.next != &tail);
203 return get(head.next);
206 const T* back()
const {
207 assert(myself ==
this);
208 assert(tail.prev != &head);
209 assert(head.next !=
nullptr);
210 assert(tail.prev !=
nullptr);
211 return get(tail.prev);
215 assert(myself ==
this);
216 assert(head.next !=
nullptr);
217 assert(tail.prev !=
nullptr);
218 return Iterator{ head.next, head.next->next };
222 assert(myself ==
this);
223 assert(head.next !=
nullptr);
224 assert(tail.prev !=
nullptr);
225 return Iterator{ &tail,
nullptr };
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....