47 #define LINKED_LIST_INIT { NULL, NULL } 52 #define LINKED_LIST_ELEMENT_INIT { NULL, NULL } 146 #define List_UntypedForEach(LINKEDLIST, ITEM) \ 147 if ((LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_LISTS && (NULL == (LINKEDLIST))) || \ 148 (NULL == (LINKEDLIST)->first)) \ 151 for ((ITEM) = (LINKEDLIST)->first; \ 153 (ITEM) = (ITEM)->next) 178 #define List_ForEach(LINKEDLIST, TYPE, ITEM, MEMBER) \ 179 if ((LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_LISTS && (NULL == (LINKEDLIST))) || \ 180 (NULL == (LINKEDLIST)->first)) \ 183 for ((ITEM) = CONTAINER_OF((LINKEDLIST)->first, MEMBER, TYPE); \ 186 (NULL == ((ITEM)->MEMBER).next) \ 188 : CONTAINER_OF(((ITEM)->MEMBER).next, MEMBER, TYPE)) 222 #define List_RemovableForEach(LINKEDLIST, TYPE, ITEM, MEMBER, ITERATOR) \ 223 if ((LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_LISTS && (NULL == (LINKEDLIST))) || \ 224 (NULL == (LINKEDLIST)->first)) \ 227 for (STATIC_CHECK_TYPE((*(ITERATOR)), Lz_LinkedListElement), \ 228 (ITERATOR) = (LINKEDLIST)->first, \ 229 (ITEM) = CONTAINER_OF((LINKEDLIST)->first, MEMBER, TYPE); \ 233 ((ITERATOR) = (NULL == (ITERATOR)) ? \ 234 (LINKEDLIST)->first : (ITERATOR)->next), \ 235 ((ITEM) = (NULL == (ITERATOR)) ? \ 236 NULL : CONTAINER_OF((ITERATOR), MEMBER, TYPE))) struct _Lz_LinkedListElement Lz_LinkedListElement
Represents an element of a doubly linked list.
void List_InsertAfter(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element after another in an Lz_LinkedList.
#define _EXTERN_C_DECL_BEGIN
Open C++ header file declarations.
bool List_IsEmpty(const Lz_LinkedList *const linkedList)
Test if an Lz_LinkedList is empty.
void List_InsertBefore(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element before another in a Lz_LinkedList.
Include appropriate config file.
Lz_LinkedListElement * List_PointFirst(const Lz_LinkedList *const linkedList)
Return a pointer to the first element of an existing linked list.
void List_Append(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the last element of an existing Lz_LinkedList.
Lz_LinkedListElement * List_PickFirst(Lz_LinkedList *const linkedList)
Return the first element of an existing linked list.
void List_InitLinkedList(Lz_LinkedList *const linkedList)
Initialize an Lz_LinkedList.
struct _Lz_LinkedListElement * next
A pointer to the next element in the list.
void List_InitLinkedListElement(Lz_LinkedListElement *const item)
Initialize an Lz_LinkedListElement.
Represents the main container for doubly linked elements.
void List_Prepend(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the first element of an existing Lz_LinkedList. ...
Lz_LinkedListElement * List_PointElementAt(const Lz_LinkedList *const linkedList, const size_t index)
Point to an indexed element in an Lz_LinkedList, starting at index 0.
void List_AppendList(Lz_LinkedList *const linkedListDestination, Lz_LinkedList *const linkedListToMove)
Move the content of an Lz_LinkedList to the end of an existing Lz_LinkedList.
Lz_LinkedListElement * last
A pointer to the last element of the linked list.
Lz_LinkedListElement * first
A pointer to the first element of the linked list.
Basic type definitions and useful macros.
struct _Lz_LinkedListElement * prev
A pointer to the previous element in the list.
Represents an element of a doubly linked list.
#define _EXTERN_C_DECL_END
Close C++ header file declarations.
Lz_LinkedListElement * List_Remove(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const itemToRemove)
Remove an element from an Lz_LinkedList.