Go to the source code of this file.
Macros | |
#define | CL_LIST_FOREACH(__type, __name, __list, ...) |
Macro to iterate over the elements of the list. | |
#define | CL_LIST_FOREACH_PTR(__type, __name, __list, ...) |
Macro to iterate over the elements of the list with a pointer to the current element. | |
Typedefs | |
typedef struct __List | CL_List |
Functions | |
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. | |
void | CL_ListFree (CL_List *const list) |
Frees the memory previously assigned to the list. | |
CL_Error | CL_ListPushBack (CL_List *const list, const void *const elem) |
Adds an element at the end of the list. | |
CL_Error | CL_ListPushFront (CL_List *const list, const void *const elem) |
Adds an element at the front of the list. | |
void | CL_ListPopBack (CL_List *const list, void *out_elem) |
Removes the last element from the list, optionally returning it. | |
void | CL_ListPopFront (CL_List *const list, void *out_elem) |
Removes the first element from the list, optionally returning it. | |
CL_Error | CL_ListGet (const CL_List *const list, u32 index, void *out_elem) |
Gets an element at the specified index. | |
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_Error | CL_ListGetLast (const CL_List *const list, void *out_elem) |
Gets the last element from the list. | |
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. | |
CL_Error | CL_ListInsertAt (CL_List *const list, u32 index, const void *const elem) |
Inserts an element at the specified index. | |
CL_Error | CL_ListRemoveAt (CL_List *const list, u32 index, void *out_elem) |
Removes an element at the specified index. | |
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. | |
void | CL_ListClear (CL_List *const list) |
Removes all elements from the list. | |
u32 | CL_ListSize (const CL_List *const list) |
Gets the number of elements in the list. | |
bool | CL_ListIsEmpty (const CL_List *const list) |
Checks if the list is empty. | |
#define CL_LIST_FOREACH | ( | __type, | |
__name, | |||
__list, | |||
... | |||
) |
Macro to iterate over the elements of the list.
__type | The type of the elements in the list. |
__name | The name of the variable to hold the current element. |
__list | The list to iterate over. |
... | The code to execute for each element. |
Definition at line 20 of file cl_list.h.
#define CL_LIST_FOREACH_PTR | ( | __type, | |
__name, | |||
__list, | |||
... | |||
) |
Macro to iterate over the elements of the list with a pointer to the current element.
__type | The type of the elements in the list. |
__name | The name of the variable to hold the current element. |
__list | The list to iterate over. |
... | The code to execute for each element. |
Definition at line 33 of file cl_list.h.
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.
alloc | The allocator to use for memory allocation. |
elem_sz | The size of each element in the list. |
Definition at line 43 of file cl_list.c.
void CL_ListClear | ( | CL_List *const | list | ) |
Removes all elements from the list.
list | The list to clear. |
Definition at line 316 of file cl_list.c.
void CL_ListFree | ( | CL_List *const | list | ) |
Frees the memory previously assigned to the list.
list | The list to release the memory of. |
Gets an element at the specified index.
list | The list to get the element from. |
index | The index of the element to get. |
out_elem | [OUTPUT] The element at the specified index. |
Gets an element at the specified index as a pointer, so the user can modify it.
list | The list to get the element from. |
index | The index of the element to get. |
out_elem | [OUTPUT] A pointer to the element at the specified index. |
Inserts an element at the specified index.
list | The list to insert the element to. |
index | The index to insert the element at. |
elem | The element to insert. |
Definition at line 228 of file cl_list.c.
bool CL_ListIsEmpty | ( | const CL_List *const | list | ) |
void CL_ListPopBack | ( | CL_List *const | list, |
void * | out_elem | ||
) |
Removes the last element from the list, optionally returning it.
list | The list to remove the last element from. |
out_elem | [OUTPUT] The removed element, if not NULL. |
void CL_ListPopFront | ( | CL_List *const | list, |
void * | out_elem | ||
) |
Removes the first element from the list, optionally returning it.
list | The list to remove the first element from. |
out_elem | [OUTPUT] The removed element, if not NULL. |
Removes an element at the specified index.
list | The list to remove the element from. |
index | The index of the element to remove. |
out_elem | [OUTPUT] The removed element, if not NULL. |
Definition at line 260 of file cl_list.c.
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.
list | The list to search in. |
elem | The element to search for. |
compare_fn | The comparison function. |
out_elem | [OUTPUT] The index of the element, if found and not NULL. |