|
cbase 1.46.11
C/C++ Static Template
|
Zero-allocation macros for pushing/popping nodes in intrusive linked lists. More...
Macros | |
| #define | DLL_PUSH_BACK_NP(f, l, n, next, prev) |
| Pushes a node to the back of a doubly linked list (Custom pointer names). | |
| #define | DLL_PUSH_BACK(f, l, n) |
| Pushes a node to the back of a doubly linked list. | |
| #define | DLL_PUSH_FRONT(f, l, n) |
| Pushes a node to the front of a doubly linked list. | |
| #define | DLL_REMOVE_NP(f, l, n, next, prev) |
| Removes a node from a doubly linked list (Custom pointer names). | |
| #define | DLL_REMOVE(f, l, n) |
| Removes a node from a doubly linked list. | |
| #define | SLL_QUEUE_PUSH_N(f, l, n, next) |
| Pushes a node to a singly linked queue (Custom pointer name). | |
| #define | SLL_QUEUE_PUSH(f, l, n) |
| Pushes a node to the back of a singly linked queue. | |
| #define | SLL_STACK_PUSH_N(f, n, next) |
| Pushes a node to the top of a singly linked stack (Custom pointer name). | |
| #define | SLL_STACK_PUSH(f, n) |
| Pushes a node to the top of a singly linked stack. | |
| #define | SLL_STACK_POP_N(f, next) |
| Pops a node from the top of a singly linked stack (Custom pointer name). | |
| #define | SLL_STACK_POP(f) |
| Pops a node from the top of a singly linked stack. | |
Zero-allocation macros for pushing/popping nodes in intrusive linked lists.
Intrusive linked lists require the data structures to contain their own next and/or prev pointers. These macros handle the pointer wiring automatically without needing to call malloc or wrap your data in a generic node struct.
| #define DLL_PUSH_BACK | ( | f, | |
| l, | |||
| n ) |
Pushes a node to the back of a doubly linked list.
Assumes the node struct has pointers exactly named next and prev.
Example:
| f | Pointer to the first (head) element. |
| l | Pointer to the last (tail) element. |
| n | Pointer to the new node to insert. |
Definition at line 473 of file base_macros.h.
| #define DLL_PUSH_BACK_NP | ( | f, | |
| l, | |||
| n, | |||
| next, | |||
| prev ) |
Pushes a node to the back of a doubly linked list (Custom pointer names).
| f | Pointer to the first (head) element of the list. |
| l | Pointer to the last (tail) element of the list. |
| n | Pointer to the new node to insert. |
| next | The literal variable name of the 'next' pointer inside the struct. |
| prev | The literal variable name of the 'prev' pointer inside the struct. |
Definition at line 450 of file base_macros.h.
| #define DLL_PUSH_FRONT | ( | f, | |
| l, | |||
| n ) |
Pushes a node to the front of a doubly linked list.
Assumes the node struct has pointers exactly named next and prev.
| f | Pointer to the first (head) element. |
| l | Pointer to the last (tail) element. |
| n | Pointer to the new node to insert. |
Definition at line 484 of file base_macros.h.
| #define DLL_REMOVE | ( | f, | |
| l, | |||
| n ) |
Removes a node from a doubly linked list.
Safely unlinks the node and updates the head/tail pointers if the node was at the boundary of the list. Assumes next and prev pointers.
| f | Pointer to the first (head) element. |
| l | Pointer to the last (tail) element. |
| n | Pointer to the node to remove. |
Definition at line 509 of file base_macros.h.
| #define DLL_REMOVE_NP | ( | f, | |
| l, | |||
| n, | |||
| next, | |||
| prev ) |
Removes a node from a doubly linked list (Custom pointer names).
| f | Pointer to the first (head) element of the list. |
| l | Pointer to the last (tail) element of the list. |
| n | Pointer to the node to remove (must currently be in the list). |
| next | The literal variable name of the 'next' pointer. |
| prev | The literal variable name of the 'prev' pointer. |
Definition at line 494 of file base_macros.h.
| #define SLL_QUEUE_PUSH | ( | f, | |
| l, | |||
| n ) |
Pushes a node to the back of a singly linked queue.
Adds to the tail (l). Assumes the node struct has a pointer named next.
| f | Pointer to the first (head) element. |
| l | Pointer to the last (tail) element. |
| n | Pointer to the new node to insert. |
Definition at line 530 of file base_macros.h.
| #define SLL_QUEUE_PUSH_N | ( | f, | |
| l, | |||
| n, | |||
| next ) |
Pushes a node to a singly linked queue (Custom pointer name).
| f | Pointer to the first (head) element. |
| l | Pointer to the last (tail) element. |
| n | Pointer to the new node. |
| next | The literal variable name of the 'next' pointer. |
Definition at line 518 of file base_macros.h.
| #define SLL_STACK_POP | ( | f | ) |
Pops a node from the top of a singly linked stack.
Advances the head pointer to the next element. It does not return the popped node, it merely updates the pointer. Assumes the node struct has a pointer named next.
| f | Pointer to the top (head) element. |
Definition at line 565 of file base_macros.h.
| #define SLL_STACK_POP_N | ( | f, | |
| next ) |
Pops a node from the top of a singly linked stack (Custom pointer name).
| f | Pointer to the top (head) element. |
| next | The literal variable name of the 'next' pointer. |
Definition at line 555 of file base_macros.h.
| #define SLL_STACK_PUSH | ( | f, | |
| n ) |
Pushes a node to the top of a singly linked stack.
Adds to the head (f). Assumes the node struct has a pointer named next.
| f | Pointer to the top (head) element. |
| n | Pointer to the new node to insert. |
Definition at line 548 of file base_macros.h.
| #define SLL_STACK_PUSH_N | ( | f, | |
| n, | |||
| next ) |
Pushes a node to the top of a singly linked stack (Custom pointer name).
| f | Pointer to the top (head) element. |
| n | Pointer to the new node. |
| next | The literal variable name of the 'next' pointer. |
Definition at line 538 of file base_macros.h.