Module for managing linked lists.
More...
Module for managing linked lists.
The SRMList module provides a simple linked list data structure and functions for creating, manipulating, and iterating over lists of pointers.
◆ SRMList
typedef struct SRMListStruct SRMList |
◆ SRMListItem
◆ srmListCreate()
Create a new empty linked list.
- Returns
- A pointer to the newly created SRMList.
◆ srmListClear()
void srmListClear |
( |
SRMList * |
list | ) |
|
Clear all items from a linked list without deallocating the list itself.
- Parameters
-
list | A pointer to the SRMList to clear. |
◆ srmListDestroy()
void srmListDestroy |
( |
SRMList * |
list | ) |
|
Destroy a linked list.
- Parameters
-
list | A pointer to the SRMList to destroy. |
- Note
- The actual data contained in each item is not automatically freed.
◆ srmListGetFront()
Get the front (head) item of a linked list.
- Parameters
-
- Returns
- A pointer to the front SRMListItem, or
NULL
if the list is empty.
◆ srmListGetBack()
Get the back (tail) item of a linked list.
- Parameters
-
- Returns
- A pointer to the back SRMListItem, or
NULL
if the list is empty.
◆ srmListAppendData()
Append data to the end of a linked list.
- Parameters
-
list | A pointer to the SRMList. |
data | A pointer to the data to append. |
- Returns
- A pointer to the newly created SRMListItem.
◆ srmListPrependData()
Prepend data to the front of a linked list.
- Parameters
-
list | A pointer to the SRMList. |
data | A pointer to the data to prepend. |
- Returns
- A pointer to the newly created SRMListItem.
◆ srmListInsertData()
Insert data after a specific item in a linked list.
- Parameters
-
list | A pointer to the SRMList. |
prev | A pointer to the SRMListItem after which the data should be inserted. |
data | A pointer to the data to insert. |
- Returns
- A pointer to the newly created SRMListItem.
◆ srmListPopFront()
void* srmListPopFront |
( |
SRMList * |
list | ) |
|
Pop the front (head) item from a linked list and return its data.
- Parameters
-
- Returns
- A pointer to the data from the popped SRMListItem, or
NULL
if the list is empty.
- Note
- The actual data contained in each item is not automatically freed.
◆ srmListPopBack()
void* srmListPopBack |
( |
SRMList * |
list | ) |
|
Pop the back (tail) item from a linked list and return its data.
- Parameters
-
- Returns
- A pointer to the data from the popped SRMListItem, or
NULL
if the list is empty.
- Note
- The actual data contained in each item is not automatically freed.
◆ srmListRemoveItem()
Remove a specific item from a linked list and return its data.
- Parameters
-
- Returns
- A pointer to the data from the removed SRMListItem, or
NULL
if the item is not found.
- Note
- The actual data contained in each item is not automatically freed.
◆ srmListGetLength()
Get the length (number of items) in a linked list.
- Parameters
-
- Returns
- The number of items in the list.
◆ srmListIsEmpty()
Check if a linked list is empty.
- Parameters
-
- Returns
- 1 if the list is empty, 0 if it contains items.
◆ srmListItemGetList()
Get the linked list associated with an SRMListItem.
- Parameters
-
- Returns
- A pointer to the SRMList that contains the item.
◆ srmListItemGetNext()
Get the next item in the linked list after the given SRMListItem.
- Parameters
-
- Returns
- A pointer to the next SRMListItem, or
NULL
if the item is the last in the list.
◆ srmListItemGetPrev()
Get the previous item in the linked list before the given SRMListItem.
- Parameters
-
- Returns
- A pointer to the previous SRMListItem, or
NULL
if the item is the first in the list.
◆ srmListItemGetData()
Get the data associated with an SRMListItem.
- Parameters
-
- Returns
- A pointer to the data associated with the item.
◆ srmListItemSetData()
void srmListItemSetData |
( |
SRMListItem * |
item, |
|
|
void * |
data |
|
) |
| |
Set the data associated with an SRMListItem.
- Parameters
-
item | A pointer to the SRMListItem. |
data | A pointer to the data to associate with the item. |