39 #define IL_NEW() NEW(IntrusiveList) 41 #define IL_EMPTY(this) (this.il_head == NULL) 43 #define IL_FIRST(this) (this.il_head) 44 #define IL_LAST(this) (this.il_tail) 45 #define IL_PEEK(this) (this.il_tail) 50 assert(
this,
return false);
51 return it.(this.il_nextfld) || this.il_head == it || this.il_tail == it;
62 .entity il_next = this.il_nextfld;
63 .entity il_prev = this.il_prevfld;
66 entity tail = it.(il_prev) = this.il_tail;
67 tail ? (tail.(il_next) = it) : this.il_head = it;
81 .entity il_next = this.il_nextfld;
82 .entity il_prev = this.il_prevfld;
85 entity head = it.(il_next) = this.il_head;
86 head ? (head.(il_prev) = it) : this.il_tail = it;
99 .entity il_next = this.il_nextfld;
100 .entity il_prev = this.il_prevfld;
102 if (!this.il_tail)
return NULL;
105 if (prev) (this.il_tail =
prev).(il_next) =
NULL;
106 else this.il_head = this.il_tail =
NULL;
117 .entity il_next = this.il_nextfld;
118 .entity il_prev = this.il_prevfld;
120 if (!this.il_head)
return NULL;
123 if (next) (this.il_head =
next).(il_prev) =
NULL;
124 else this.il_head = this.il_tail =
NULL;
135 .entity il_next = this.il_nextfld;
136 .entity il_prev = this.il_prevfld;
140 entity ohead = this.il_head;
141 entity otail = this.il_tail;
142 next ? next.(il_prev) = prev : this.il_tail = prev;
143 prev ? prev.(il_next) = next : this.il_head = next;
144 LOG_DEBUGF(
"remove %i (%i :: %i), head: %i -> %i, tail: %i -> %i", it, it.(il_prev), it.(il_next), ohead, this.il_head, otail, this.il_tail);
145 it.(il_next) = it.(il_prev) =
NULL;
151 #define IL_CLEAR(this) \ 153 IntrusiveList __il = this; \ 155 .entity il_prev = __il.il_prevfld; \ 156 IL_EACH(__il, true, it.(il_next) = it.(il_prev) = NULL); \ 157 __il.il_head = __il.il_tail = NULL; \ 163 #define IL_DELETE(this) \ 169 #define IL_EACH(this, cond, body) \ 171 IntrusiveList _il = this; \ 173 .entity il_next = _il.il_nextfld; \ 175 for (entity _next, _it = _il.il_head; _it; (_it = _next, ++i)) \ 177 const noref entity it = _it; \ 178 _next = it.(il_next); \ 179 if (cond) { LAMBDA(body) } \ 188 #define IL_FLOOR(n) ((n) | 0) 189 #define IL_CEIL(n) IL_FLOOR((n) + 0.5) 191 #define IL_LISTS_PER_BIT IL_CEIL(IL_MAX / (3 * 24)) 196 .entity nextfld, prevfld;
199 if (idx >= IL_MAX) idx -=
IL_MAX;
202 if (!il_links[idx]) {
203 il_links[idx] =
this;
208 if (bit < (1 * 24)) this.
il_listmask =
'1 0 0' * (1 << (bit - (0 * 24)));
209 else if (bit < (2 * 24)) this.
il_listmask =
'0 1 0' * (1 << (bit - (1 * 24)));
210 else if (bit < (3 * 24)) this.
il_listmask =
'0 0 1' * (1 << (bit - (2 * 24)));
214 this.il_nextfld = nextfld;
215 this.il_prevfld = prevfld;
234 for (
int i = 0; i <
IL_MAX; ++i) {
238 for (
entity next, it = list.il_head; it; it = next) {
256 for (
int i = 0; i <
IL_MAX; ++i) {
258 if ((lists & list.il_listmask) &&
IL_CONTAINS(list,
this)) {
const int IL_MAX
Maximum amount of creatable lists.
#define DESTRUCTOR(cname)
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
#define IL_CLEAR(this)
Remove all elements.
ERASEABLE void IL_DTOR(entity this)
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
ERASEABLE bool IL_CONTAINS(IntrusiveList this, entity it)
ERASEABLE void IL_ENDFRAME()
ERASEABLE entity IL_UNSHIFT(IntrusiveList this, entity it)
Push to head.
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
ERASEABLE entity IL_SHIFT(IntrusiveList this)
Pop from head.
vector(float skel, float bonenum) _skel_get_boneabs_hidden
entity il_links_flds[IL_MAX *2]
ERASEABLE entity IL_POP(IntrusiveList this)
Pop from tail.
void ONREMOVE(entity this)
ERASEABLE void IL_INIT(entity this)
IntrusiveList il_links[IL_MAX]