2
3
4
5
6
7
8
9
10
11
12#ifndef GIMBAL_RING_LIST_H
13#define GIMBAL_RING_LIST_H
17#include "../core/gimbal_result.h"
18#include <gimbal/meta/classes/gimbal_opaque.h>
19#include <gimbal/meta/ifaces/gimbal_itable_variant.h>
26
27
28
30#define GBL_RING_LIST_CLASS(klass) (GBL_CLASS_CAST
(GblRingList, klass))
34
35
36
37
38#define GblRingList_foreach(...) GblRingList_foreachDefault_
(__VA_ARGS__)
40#define GBL_SELF_TYPE GblRingList
47
48
49
50
51
52
53
54
60
61
62
64typedef GblBool (*GblRingListIterFn)(
void* pValue,
void* pClosure);
70typedef GBL_RESULT (*GblRingListDtorFn)(
void* pValue,
void* pClosure);
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
140
141
142
149 GblRingListDtorFn pFnDtor,
160
161
162
172
173
174
190
191
192
223
224
225
242
243
244
255 GblRingListIterFn pFnIt,
265#define GblRingList_copy(...) GblRingList_copyDefault_
(__VA_ARGS__)
266#define GblRingList_unref(...) GblRingList_unrefDefault_
(__VA_ARGS__)
270#define GblRingList_insertSorted(...) GblRingList_insertSortedDefault_
(__VA_ARGS__)
271#define GblRingList_splice(...) GblRingList_spliceDefault_
(__VA_ARGS__)
272#define GblRingList_popBack(...) GblRingList_popBackDefault_
(__VA_ARGS__)
273#define GblRingList_popFront(...) GblRingList_popFrontDefault_
(__VA_ARGS__)
274#define GblRingList_remove(...) GblRingList_removeDefault_
(__VA_ARGS__)
275#define GblRingList_sort(...) GblRingList_sortDefault_
(__VA_ARGS__)
276#define GblRingList_iterate(...) GblRingList_iterateDefault_
(__VA_ARGS__)
277#define GblRingList_find(...) GblRingList_findDefault_
(__VA_ARGS__)
282#define GblRingList_copyDefault_(...)
284#define GblRingList_copyDefault__(list, cpFn, cl, ...)
287#define GblRingList_unrefDefault_(...)
289#define GblRingList_unrefDefault__(list, dtor, cl, ...)
292#define GblRingList_insertSortedDefault_(...)
294#define GblRingList_insertSortedDefault__(list, data, cmp, cl, ...)
297#define GblRingList_spliceDefault_(...)
298 GblRingList_spliceDefault__
(__VA_ARGS__, -1
)
299#define GblRingList_spliceDefault__(list1, list2, index, ...)
302#define GblRingList_popBackDefault_(...)
303 GblRingList_popBackDefault__
(__VA_ARGS__, 1
)
304#define GblRingList_popBackDefault__(list, count, ...)
307#define GblRingList_popFrontDefault_(...)
308 GblRingList_popFrontDefault__
(__VA_ARGS__, 1
)
309#define GblRingList_popFrontDefault__(list, count, ...)
312#define GblRingList_removeDefault_(...)
313 GblRingList_removeDefault__
(__VA_ARGS__, 1
)
314#define GblRingList_removeDefault__(list, idx, count, ...)
317#define GblRingList_sortDefault_(...)
319#define GblRingList_sortDefault__(list, cmp, cl, ...)
322#define GblRingList_foreachDefault_(...)
323 GblRingList_foreachDefault__
(__VA_ARGS__, void*)
324#define GblRingList_foreachDefault__(list, item, type, ...)
325 GblRingList_foreachImpl_
(list, item, type)
326#define GblRingList_foreachImpl_(list, item, type)
333#define GblRingList_iterateDefault_(...)
334 GblRingList_iterateDefault__
(__VA_ARGS__, GBL_NULL)
335#define GblRingList_iterateDefault__(list, it, cl, ...)
338#define GblRingList_findDefault_(...)
340#define GblRingList_findDefault__(list, val, cmp, cl, ...)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_CLASS_DERIVE(...)
#define GBL_APPEND_LINE(a)
size_t GblRingList_find(const GblRingList *pSelf, const void *pVal, GblRingListCmpFn pFnCmp, void *pCl)
Searches the list for an entry with the given value, or for an entry which matches the value based on...
GBL_RESULT GblRingList_insert(GblRingList *pSelf, intptr_t index,...)
Inserts the comma-separated list of values into the given GblRingList, so that the first value is at ...
GBL_RESULT GblRingList_pushFrontVaList(GblRingList *pSelf, va_list *plist)
Equivalent to GblRingList_pushFront(), except taking a va_list*, rather than a variadic argument list...
void * GblRingList_replace(GblRingList *pSelf, intptr_t index, void *pData)
Replaces the entry within the given GblRingList located at pIndex with the pData value,...
#define GblRingList_create(...)
#define GblRingList_insert(self,...)
GblType GblRingList_type(void)
Returns the GblType UUID associated with GblRingList.
GblBool GblRingList_iterate(GblRingList *pSelf, GblRingListIterFn pFnIt, void *pCl)
Iterates over every entry within the given GblRingList, passing their values to the given iterator fu...
void GblRingList_sort(GblRingList *pSelf, GblRingListCmpFn pFnCmp, void *pCl)
Sorts the given GblRingList, optionally using a user-specified comparator which can optionally take a...
GblBool GblRingList_empty(const GblRingList *pSelf)
Returns true if the given GblRingList has no entries held within it.
GBL_RESULT GblRingList_pushFront(GblRingList *pSelf,...)
Adds a comma-separated list of values to the front of the given GblRingList.
GblRingList * GblRingList_ref(const GblRingList *pSelf)
Returns a new reference to an existing GblRingList, incrementing its reference counter by 1.
#define GblRingList_insertSorted(...)
GblRingList * GblRingList_create(void *pData,...)
Creates a new GblRingList, given an initial value and an optional list of additional values,...
GblRingList * GblRingList_copy(const GblRingList *pSelf, GblRingListCopyFn pFnCpy, void *pCl)
Creates a copy of the given GblRingList, optionally deep-copying each entry by using the user-provide...
void * GblRingList_popBack(GblRingList *pSelf, size_t count)
Removes the last entry from the given list, returning its previously held value, or NULL if the list ...
#define GblRingList_popFront(...)
GblBool GblRingList_splice(GblRingList *pSelf, GblRingList *pOther, int32_t index)
Joins pOther into the given GblRingList such that its first entry is positioned at the given index,...
void * GblRingList_front(const GblRingList *pSelf)
Returns a pointer to the value held within the first entry of the list, or NULL if the list is empty.
#define GblRingList_pushBack(self,...)
#define GblRingList_splice(...)
#define GblRingList_unref(...)
void * GblRingList_back(const GblRingList *pSelf)
Returns a pointer to the value held within the last entry of the list, or NULL if the list is empty.
GBL_RESULT GblRingList_clear(GblRingList *pSelf)
Erases all entries from the GblRingList, returning its size back to 0.
GBL_RESULT GblRingList_pushBackVaList(GblRingList *pSelf, va_list *pList)
Equivalent to GblRingList_pushBack(), except taking a va_list*, rather than a variadic argument list.
void *(* GblRingListCopyFn)(const void *pValue, void *pClosure)
Returns a copy of the value of each entry within a GblRingList, also getting passed back the closure ...
void * GblRingList_remove(GblRingList *pSelf, intptr_t index, size_t count)
Removes count items from the given GblRingList, starting at the given index, returning the value prev...
#define GblRingList_remove(...)
void * GblRingList_extract(GblRingList *pSelf, GblRingList *pNode)
Returns the value which was held by the given GblRingList node within the given list,...
GblRingList * GblRingList_createEmpty(void)
Creates a new, empty GblRingList of size 0 and returns a reference to it.
#define GblRingList_copy(...)
GBL_RESULT GblRingList_insertVaList(GblRingList *pSelf, intptr_t index, va_list *pList)
Equivalent to GblRingList_insert(), except taking a va_list* rather than a variadic argument list.
#define GblRingList_pushFront(self,...)
size_t GblRingList_size(const GblRingList *pSelf)
Returns the number of entries held by the given GblRingList.
GblRefCount GblRingList_refCount(const GblRingList *pSelf)
Returns the number of active references to the given GblRingList.
#define GblRingList_find(...)
GblRefCount GblRingList_unref(const GblRingList *pSelf, GblRingListDtorFn pFnDtor, void *pCl)
Unreferences an existing GblRingList, destroying it if this was the last reference,...
void * GblRingList_popFront(GblRingList *pSelf, size_t count)
Removes the first entry from the given list, returning its previously held value, or NULL if the list...
#define GblRingList_sort(...)
void * GblRingList_at(const GblRingList *pSelf, intptr_t index)
Linearly traverses the list to the given index, returning a pointer to the value held within that ent...
GBL_RESULT GblRingList_pushBack(GblRingList *pSelf,...)
Adds a comma-separated list of values to the end of the given GblRingList.
void GblRingList_rotate(GblRingList *pSelf, intptr_t n)
Rotates the positions of all entries within the given GblRingList, such that they ahve been offset by...
#define GblRingList_popBack(...)
void GblRingList_reverse(GblRingList *pSelf)
Reverses the order of the entire GblRingList, such that the tail becomes the head entry,...
int(* GblRingListCmpFn)(const void *pVal1, const void *pVal2, void *pClosure)
Comparator callback for comparing the values of two different entries within a GblRingList,...
#define GblRingList_iterate(...)
GBL_RESULT GblRingList_insertSorted(GblRingList *pSelf, void *pData, GblRingListCmpFn pFnCmp, void *pCl)
Inserts a value into a sorted list, optionally taking a comparator for sort direction and an optional...
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
GblType innerType
GblType UUID representing the type of values stored within the GblRingList, defaulting to GBL_POINTER...
Non-intrusive circularly doubly linked list with C++-style STL API.
struct GblRingList * pNext
Points to next node within the list (or wraps back to first node, if list tail).
GblDoublyLinkedListNode listNode
< Unionization of linked list node pointers, so they can be referred to generically or strongly-typed...
void * pData
List entries contain void* pointers to arbitrary data payloads.
struct GblRingList * pPrev
Points to previous node within the list (or wraps back to last, if list head)
uintptr_t size
< Unionization between payload data types for the list head and list nodes.