Xonotic
linkedlist.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  LinkedList
 
class  LinkedListNode
 

Macros

#define EVAL_LL_CLEAR(...)   __VA_ARGS__
 
#define EVAL_LL_DELETE(...)   __VA_ARGS__
 
#define LL_CLEAR(...)   EVAL_LL_CLEAR(OVERLOAD(LL_CLEAR, __VA_ARGS__))
 
#define LL_CLEAR_1(this)   LL_CLEAR_2(this, LAMBDA())
 
#define LL_CLEAR_2(this, dtor)
 
#define LL_DELETE(...)   EVAL_LL_DELETE(OVERLOAD(LL_DELETE, __VA_ARGS__))
 
#define LL_DELETE_1(this)   LL_DELETE_2(this, LAMBDA())
 
#define LL_DELETE_2(this, dtor)
 
#define LL_EACH(list, cond, body)
 
#define LL_EMPTY(ll)   (ll.ll_head == NULL)
 
#define LL_NEW()   NEW(LinkedList)
 

Functions

entity LL_POP (LinkedList this)
 Pop from tail. More...
 
entity LL_PUSH (LinkedList this, entity e)
 Push to tail. More...
 

Macro Definition Documentation

◆ EVAL_LL_CLEAR

#define EVAL_LL_CLEAR (   ...)    __VA_ARGS__

Definition at line 48 of file linkedlist.qh.

◆ EVAL_LL_DELETE

#define EVAL_LL_DELETE (   ...)    __VA_ARGS__

Definition at line 64 of file linkedlist.qh.

◆ LL_CLEAR

#define LL_CLEAR (   ...)    EVAL_LL_CLEAR(OVERLOAD(LL_CLEAR, __VA_ARGS__))

Definition at line 47 of file linkedlist.qh.

◆ LL_CLEAR_1

#define LL_CLEAR_1 (   this)    LL_CLEAR_2(this, LAMBDA())

Definition at line 49 of file linkedlist.qh.

◆ LL_CLEAR_2

#define LL_CLEAR_2 (   this,
  dtor 
)
Value:
MACRO_BEGIN \
LinkedList _ll = this; \
assert(_ll); \
while (_ll.ll_tail) \
{ \
entity it = LL_POP(_ll); \
if (!it) continue; \
delete(it); \
} \
MACRO_END
#define delete(this)
Definition: oo.qh:72
entity LL_POP(LinkedList this)
Pop from tail.
Definition: linkedlist.qh:34

Definition at line 50 of file linkedlist.qh.

◆ LL_DELETE

#define LL_DELETE (   ...)    EVAL_LL_DELETE(OVERLOAD(LL_DELETE, __VA_ARGS__))

Definition at line 63 of file linkedlist.qh.

◆ LL_DELETE_1

#define LL_DELETE_1 (   this)    LL_DELETE_2(this, LAMBDA())

Definition at line 65 of file linkedlist.qh.

◆ LL_DELETE_2

#define LL_DELETE_2 (   this,
  dtor 
)
Value:
LL_CLEAR_2(this, dtor); \
delete(this); \
this = NULL; \
MACRO_END
#define NULL
Definition: post.qh:17
#define LL_CLEAR_2(this, dtor)
Definition: linkedlist.qh:50

Definition at line 66 of file linkedlist.qh.

◆ LL_EACH

#define LL_EACH (   list,
  cond,
  body 
)
Value:
MACRO_BEGIN \
noref int i = 0; \
for (entity _it = list.ll_head; _it; (_it = _it.ll_next, ++i)) \
{ \
ITER_CONST noref entity it = _it.ll_data; \
if (cond) { body } \
} \
MACRO_END
entity() spawn

Definition at line 73 of file linkedlist.qh.

Referenced by Draw_ShowNames(), and Draw_ShowNames_All().

◆ LL_EMPTY

#define LL_EMPTY (   ll)    (ll.ll_head == NULL)

Definition at line 16 of file linkedlist.qh.

◆ LL_NEW

#define LL_NEW ( )    NEW(LinkedList)

Definition at line 14 of file linkedlist.qh.

Referenced by STATIC_INIT().

Function Documentation

◆ LL_POP()

entity LL_POP ( LinkedList  this)

Pop from tail.

Definition at line 34 of file linkedlist.qh.

References assert, entity(), NULL, and prev.

35 {
36  assert(this);
37  if (!this.ll_tail) return NULL;
38  LinkedListNode n = this.ll_tail;
39  entity e = n.ll_data;
40  LinkedListNode prev = n.ll_prev;
41  if (prev) (this.ll_tail = prev).ll_next = NULL;
42  else this.ll_head = this.ll_tail = NULL;
43  delete(n);
44  return e;
45 }
#define assert(expr,...)
Definition: log.qh:8
entity() spawn
prev
Definition: all.qh:66
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:

◆ LL_PUSH()

entity LL_PUSH ( LinkedList  this,
entity  e 
)

Push to tail.

Definition at line 21 of file linkedlist.qh.

References assert, and NEW.

Referenced by STATIC_INIT().

22 {
23  assert(this);
25  n.ll_data = e;
26  LinkedListNode tail = n.ll_prev = this.ll_tail;
27  this.ll_tail = (tail) ? tail.ll_next = n : this.ll_head = n;
28  return e;
29 }
#define assert(expr,...)
Definition: log.qh:8
#define NEW(cname,...)
Definition: oo.qh:105
+ Here is the caller graph for this function: