SRM  v0.7.2-1
Simple Rendering Manager
SRMList

Module for managing linked lists. More...

Detailed Description

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.

Functions

SRMListsrmListCreate ()
 Create a new empty linked list. More...
 
void srmListClear (SRMList *list)
 Clear all items from a linked list without deallocating the list itself. More...
 
void srmListDestroy (SRMList *list)
 Destroy a linked list. More...
 
SRMListItemsrmListGetFront (SRMList *list)
 Get the front (head) item of a linked list. More...
 
SRMListItemsrmListGetBack (SRMList *list)
 Get the back (tail) item of a linked list. More...
 
SRMListItemsrmListAppendData (SRMList *list, void *data)
 Append data to the end of a linked list. More...
 
SRMListItemsrmListPrependData (SRMList *list, void *data)
 Prepend data to the front of a linked list. More...
 
SRMListItemsrmListInsertData (SRMList *list, SRMListItem *prev, void *data)
 Insert data after a specific item in a linked list. More...
 
void * srmListPopFront (SRMList *list)
 Pop the front (head) item from a linked list and return its data. More...
 
void * srmListPopBack (SRMList *list)
 Pop the back (tail) item from a linked list and return its data. More...
 
void * srmListRemoveItem (SRMList *list, SRMListItem *item)
 Remove a specific item from a linked list and return its data. More...
 
UInt32 srmListGetLength (SRMList *list)
 Get the length (number of items) in a linked list. More...
 
Int32 srmListIsEmpty (SRMList *list)
 Check if a linked list is empty. More...
 
SRMListsrmListItemGetList (SRMListItem *item)
 Get the linked list associated with an SRMListItem. More...
 
SRMListItemsrmListItemGetNext (SRMListItem *item)
 Get the next item in the linked list after the given SRMListItem. More...
 
SRMListItemsrmListItemGetPrev (SRMListItem *item)
 Get the previous item in the linked list before the given SRMListItem. More...
 
void * srmListItemGetData (SRMListItem *item)
 Get the data associated with an SRMListItem. More...
 
void srmListItemSetData (SRMListItem *item, void *data)
 Set the data associated with an SRMListItem. More...
 

Typedef Documentation

◆ SRMList

typedef struct SRMListStruct SRMList

◆ SRMListItem

typedef struct SRMListItemStruct SRMListItem

Function Documentation

◆ srmListCreate()

SRMList* 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
listA pointer to the SRMList to clear.

◆ srmListDestroy()

void srmListDestroy ( SRMList list)

Destroy a linked list.

Parameters
listA pointer to the SRMList to destroy.
Note
The actual data contained in each item is not automatically freed.

◆ srmListGetFront()

SRMListItem* srmListGetFront ( SRMList list)

Get the front (head) item of a linked list.

Parameters
listA pointer to the SRMList.
Returns
A pointer to the front SRMListItem, or NULL if the list is empty.

◆ srmListGetBack()

SRMListItem* srmListGetBack ( SRMList list)

Get the back (tail) item of a linked list.

Parameters
listA pointer to the SRMList.
Returns
A pointer to the back SRMListItem, or NULL if the list is empty.

◆ srmListAppendData()

SRMListItem* srmListAppendData ( SRMList list,
void *  data 
)

Append data to the end of a linked list.

Parameters
listA pointer to the SRMList.
dataA pointer to the data to append.
Returns
A pointer to the newly created SRMListItem.

◆ srmListPrependData()

SRMListItem* srmListPrependData ( SRMList list,
void *  data 
)

Prepend data to the front of a linked list.

Parameters
listA pointer to the SRMList.
dataA pointer to the data to prepend.
Returns
A pointer to the newly created SRMListItem.

◆ srmListInsertData()

SRMListItem* srmListInsertData ( SRMList list,
SRMListItem prev,
void *  data 
)

Insert data after a specific item in a linked list.

Parameters
listA pointer to the SRMList.
prevA pointer to the SRMListItem after which the data should be inserted.
dataA 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
listA pointer to the SRMList.
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
listA pointer to the SRMList.
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()

void* srmListRemoveItem ( SRMList list,
SRMListItem item 
)

Remove a specific item from a linked list and return its data.

Parameters
listA pointer to the SRMList.
itemA pointer to the SRMListItem to remove.
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()

UInt32 srmListGetLength ( SRMList list)

Get the length (number of items) in a linked list.

Parameters
listA pointer to the SRMList.
Returns
The number of items in the list.

◆ srmListIsEmpty()

Int32 srmListIsEmpty ( SRMList list)

Check if a linked list is empty.

Parameters
listA pointer to the SRMList.
Returns
1 if the list is empty, 0 if it contains items.

◆ srmListItemGetList()

SRMList* srmListItemGetList ( SRMListItem item)

Get the linked list associated with an SRMListItem.

Parameters
itemA pointer to the SRMListItem.
Returns
A pointer to the SRMList that contains the item.

◆ srmListItemGetNext()

SRMListItem* srmListItemGetNext ( SRMListItem item)

Get the next item in the linked list after the given SRMListItem.

Parameters
itemA pointer to the SRMListItem.
Returns
A pointer to the next SRMListItem, or NULL if the item is the last in the list.

◆ srmListItemGetPrev()

SRMListItem* srmListItemGetPrev ( SRMListItem item)

Get the previous item in the linked list before the given SRMListItem.

Parameters
itemA pointer to the SRMListItem.
Returns
A pointer to the previous SRMListItem, or NULL if the item is the first in the list.

◆ srmListItemGetData()

void* srmListItemGetData ( SRMListItem item)

Get the data associated with an SRMListItem.

Parameters
itemA pointer to the SRMListItem.
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
itemA pointer to the SRMListItem.
dataA pointer to the data to associate with the item.