20#define CL_LIST_FOREACH(__type, __name, __list, ...) \
21 for (u32 __i = 0; __i < CL_ListSize(__list); __i++) \
24 CL_ListGet(__list, __i, &(__name)); \
33#define CL_LIST_FOREACH_PTR(__type, __name, __list, ...) \
34 for (u32 __i = 0; __i < CL_ListSize(__list); __i++) \
36 __type *const __name; \
37 CL_ListGetPtr(__list, __i, (void **)&(__name)); \
CL_Error CL_ListGetLastPtr(const CL_List *const list, void **out_elem)
Gets the last element from the list as a pointer, so the user can modify it.
void CL_ListPopFront(CL_List *const list, void *out_elem)
Removes the first element from the list, optionally returning it.
CL_Error CL_ListRemoveAt(CL_List *const list, u32 index, void *out_elem)
Removes an element at the specified index.
void CL_ListPopBack(CL_List *const list, void *out_elem)
Removes the last element from the list, optionally returning it.
void CL_ListClear(CL_List *const list)
Removes all elements from the list.
CL_Error CL_ListGetLast(const CL_List *const list, void *out_elem)
Gets the last element from the list.
bool CL_ListSearch(const CL_List *const list, const void *const elem, CL_CompareFn compare_fn, u32 *out_index)
Searches for an element in the list.
u32 CL_ListSize(const CL_List *const list)
Gets the number of elements in the list.
CL_Error CL_ListPushBack(CL_List *const list, const void *const elem)
Adds an element at the end of the list.
bool CL_ListIsEmpty(const CL_List *const list)
Checks if the list is empty.
void CL_ListFree(CL_List *const list)
Frees the memory previously assigned to the list.
CL_Error CL_ListGetPtr(const CL_List *const list, u32 index, void **out_elem)
Gets an element at the specified index as a pointer, so the user can modify it.
CL_List * CL_ListAlloc(MEM_Allocator *const alloc, u32 elem_sz)
Initializes a new doubly-linked list with tail, with the allocated memory provided by the user.
CL_Error CL_ListPushFront(CL_List *const list, const void *const elem)
Adds an element at the front of the list.
CL_Error CL_ListGet(const CL_List *const list, u32 index, void *out_elem)
Gets an element at the specified index.
CL_Error CL_ListInsertAt(CL_List *const list, u32 index, const void *const elem)
Inserts an element at the specified index.
int(* CL_CompareFn)(const void *, const void *)
A function pointer type for comparing two elements.
CL_Error
Specify this in the size parameter of the collections initialization to tell the library that the num...