23 if (
NULL == linkedList ||
NULL == item) {
32 linkedList->
first = item;
33 linkedList->
last = item;
40 linkedList->
last = item;
48 if (
NULL == linkedList ||
NULL == item) {
57 linkedList->
first = item;
58 linkedList->
last = item;
65 linkedList->
first = item;
73 if (
NULL == linkedListDestination ||
NULL == linkedListToMove) {
82 if (
NULL == linkedListDestination->
first) {
83 linkedListDestination->
first = linkedListToMove->
first;
89 linkedListDestination->
last = linkedListToMove->
last;
101 if (
NULL == linkedList) {
110 item = linkedList->
first;
130 if (
NULL == linkedList) {
135 return linkedList->
first;
142 if (
NULL == linkedList) {
156 if (
NULL == linkedList ||
NULL == listItem ||
NULL == itemToInsert) {
161 if (linkedList->
last == listItem) {
162 linkedList->
last = itemToInsert;
165 itemToInsert->
next = listItem->
next;
166 itemToInsert->
prev = listItem;
167 listItem->
next = itemToInsert;
176 if (
NULL == linkedList ||
NULL == listItem ||
NULL == itemToInsert) {
181 if (linkedList->
first == listItem) {
182 linkedList->
first = itemToInsert;
185 itemToInsert->
next = listItem;
186 itemToInsert->
prev = listItem->
prev;
187 listItem->
prev = itemToInsert;
201 if (
NULL == linkedList ||
NULL == itemToRemove) {
206 previousElement = itemToRemove->
prev;
215 linkedList->
last = itemToRemove->
prev;
223 return previousElement;
230 size_t currentIndex = 0;
233 if (
NULL == linkedList) {
239 if (currentIndex == index) {
255 if (
NULL == linkedList) {
260 Memory_Copy(&linkedListInit, linkedList,
sizeof(linkedListInit));
274 Memory_Copy(&linkedListElementInit, item,
sizeof(linkedListElementInit));
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.
#define LINKED_LIST_ELEMENT_INIT
Define the initialization value for the type Lz_LinkedListElement.
void List_Prepend(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the first element of an existing Lz_LinkedList. ...
Include appropriate config file.
Lz_LinkedListElement * List_Remove(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const itemToRemove)
Remove an element from an Lz_LinkedList.
#define List_UntypedForEach(LINKEDLIST, ITEM)
Run through an Lz_LinkedList like a for loop.
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.
struct _Lz_LinkedListElement * next
A pointer to the next element in the list.
Doubly linked lists interface.
void List_Append(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the last element of an existing Lz_LinkedList.
void Memory_Copy(const void *source, void *destination, const size_t size)
Copy bytes from one location to another in main memory.
Represents the main container for doubly linked elements.
void List_InitLinkedList(Lz_LinkedList *const linkedList)
Initialize an Lz_LinkedList.
Lz_LinkedListElement * last
A pointer to the last element of the linked list.
#define NULL
NULL pointer.
Lz_LinkedListElement * first
A pointer to the first element of the linked list.
const bool LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_LISTS
When 1, always check for NULL functions parameters in linked lists implementation.
Lz_LinkedListElement * List_PointFirst(const Lz_LinkedList *const linkedList)
Return a pointer to the first element of an existing linked list.
void List_InsertBefore(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element before another in a Lz_LinkedList.
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.
void List_InsertAfter(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element after another in an Lz_LinkedList.
Lz_LinkedListElement * List_PickFirst(Lz_LinkedList *const linkedList)
Return the first element of an existing linked list.
#define LINKED_LIST_INIT
Define the initialization value for the type Lz_LinkedList.
bool List_IsEmpty(const Lz_LinkedList *const linkedList)
Test if an Lz_LinkedList is empty.
void List_InitLinkedListElement(Lz_LinkedListElement *const item)
Initialize an Lz_LinkedListElement.