25 if (
NULL == linkedList ||
NULL == item) {
34 linkedList->
first = item;
35 linkedList->
last = item;
42 linkedList->
last = item;
50 if (
NULL == linkedList ||
NULL == item) {
59 linkedList->
first = item;
60 linkedList->
last = item;
67 linkedList->
first = item;
75 if (
NULL == linkedListDestination ||
NULL == linkedListToMove) {
84 if (
NULL == linkedListDestination->
first) {
85 linkedListDestination->
first = linkedListToMove->
first;
91 linkedListDestination->
last = linkedListToMove->
last;
103 if (
NULL == linkedList) {
112 item = linkedList->
first;
132 if (
NULL == linkedList) {
137 return linkedList->
first;
144 if (
NULL == linkedList) {
158 if (
NULL == linkedList ||
NULL == listItem ||
NULL == itemToInsert) {
163 if (linkedList->
last == listItem) {
164 linkedList->
last = itemToInsert;
167 itemToInsert->
next = listItem->
next;
168 itemToInsert->
prev = listItem;
169 listItem->
next = itemToInsert;
178 if (
NULL == linkedList ||
NULL == listItem ||
NULL == itemToInsert) {
183 if (linkedList->
first == listItem) {
184 linkedList->
first = itemToInsert;
187 itemToInsert->
next = listItem;
188 itemToInsert->
prev = listItem->
prev;
189 listItem->
prev = itemToInsert;
203 if (
NULL == linkedList ||
NULL == itemToRemove) {
208 previousElement = itemToRemove->
prev;
217 linkedList->
last = itemToRemove->
prev;
225 return previousElement;
232 size_t currentIndex = 0;
235 if (
NULL == linkedList) {
241 if (currentIndex == index) {
257 if (
NULL == linkedList) {
262 Memory_Copy(&linkedListInit, linkedList,
sizeof(linkedListInit));
276 Memory_Copy(&linkedListElementInit, item,
sizeof(linkedListElementInit));
Basic type definitions and useful macros.
#define NULL
NULL pointer.
Include appropriate config file.
const bool LZ_CONFIG_CHECK_NULL_PARAMETERS_IN_LISTS
When 1, always check for NULL functions parameters in linked lists implementation.
void Kernel_ManageFailure(void)
Manage a failure that can happen in a function call.
Kernel symbols definition.
void List_Append(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the last element of an existing Lz_LinkedList.
bool List_IsEmpty(const Lz_LinkedList *const linkedList)
Test if an Lz_LinkedList is empty.
Lz_LinkedListElement * List_PickFirst(Lz_LinkedList *const linkedList)
Return the first element of an existing linked list.
Lz_LinkedListElement * List_Remove(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const itemToRemove)
Remove an element from an Lz_LinkedList.
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 * List_PointFirst(const Lz_LinkedList *const linkedList)
Return a pointer to the first element of an existing linked list.
void List_InitLinkedList(Lz_LinkedList *const linkedList)
Initialize an Lz_LinkedList.
void List_Prepend(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const item)
Insert an Lz_LinkedListElement as the first element of an existing Lz_LinkedList.
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_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_InitLinkedListElement(Lz_LinkedListElement *const item)
Initialize an Lz_LinkedListElement.
void List_InsertBefore(Lz_LinkedList *const linkedList, Lz_LinkedListElement *const listItem, Lz_LinkedListElement *const itemToInsert)
Insert an element before another in a Lz_LinkedList.
Doubly linked lists interface.
#define List_UntypedForEach(LINKEDLIST, ITEM)
Run through an Lz_LinkedList like a for loop.
#define LINKED_LIST_INIT
Define the initialization value for the type Lz_LinkedList.
#define LINKED_LIST_ELEMENT_INIT
Define the initialization value for the type Lz_LinkedListElement.
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.
Lz_LinkedListElement * first
A pointer to the first element of the linked list.
Lz_LinkedListElement * last
A pointer to the last element of the linked list.
Represents an element of a doubly linked list.
struct _Lz_LinkedListElement * next
A pointer to the next element in the list.
struct _Lz_LinkedListElement * prev
A pointer to the previous element in the list.