|
libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
#include <gimbal_ring_list.h>

Data Fields | ||
| union { | ||
| GblDoublyLinkedListNode listNode | ||
| struct { | ||
| struct GblRingList * pNext | ||
| struct GblRingList * pPrev | ||
| } ringNode | ||
| }; | ||
| union { | ||
| uintptr_t size | ||
| void * pData | ||
| }; | ||
Non-intrusive circularly doubly linked list with C++-style STL API.
GblRingList is a non-intrusive circular doubly-linked list with an API mirroring C++'s std::vector, or that of an abstract List from other languges, except for the list can also be indexed from back-to-front with negative indices.
All values are stored in the form of void* pointers.
Each entry within the list is maintained as a simple GblDoublyLinkedListNode connecting it to the prevous and next entries along with a void* as a data payload (with the list head storing its size in that union field instead). While these nodes are directly accessible, a higher-level API is presented, which manages allocations and node relationships internally.
The GblRingList API has been tweaked for convenience within the C programming language. This is why many of the methods are provided as overridden macros implementing default values and function overloading for doing things such as inserting or removing multiple entries at once.
| Operation | Time Complexity |
|---|---|
| iteration | O(N) |
| insertion/removal (middle) | O(N) |
| insertion/removal (front or back) | O(1) |
| access (front or back) | O(1) |
| random access (middle) | O(N) |
Definition at line 122 of file gimbal_ring_list.h.
| GblDoublyLinkedListNode GblRingList::listNode |
< Unionization of linked list node pointers, so they can be referred to generically or strongly-typed.
Linked list node as a generic GblDoublyLinkedListNode type.
Definition at line 124 of file gimbal_ring_list.h.
| struct GblRingList* GblRingList::pNext |
Points to next node within the list (or wraps back to first node, if list tail).
Definition at line 126 of file gimbal_ring_list.h.
| struct GblRingList* GblRingList::pPrev |
Points to previous node within the list (or wraps back to last, if list head)
Definition at line 127 of file gimbal_ring_list.h.
| struct { ... } GblRingList::ringNode |
Linked list node as strongly-typed GblRingList pointers.
| uintptr_t GblRingList::size |
< Unionization between payload data types for the list head and list nodes.
List head contains the total number of nodes within the list.
Definition at line 131 of file gimbal_ring_list.h.
| void* GblRingList::pData |
List entries contain void* pointers to arbitrary data payloads.
Definition at line 132 of file gimbal_ring_list.h.