Typedefs | |
typedef _SListEntry | SListEntry |
Represents an entry in a singly-linked list. | |
typedef void(* | SListIterator )(void *data, void *user_data) |
Callback function used for iterating over a list. | |
typedef int(* | SListCompareFunc )(void *data1, void *data2) |
Callback function used to compare values in a list when sorting. | |
typedef int(* | SListEqualFunc )(void *data1, void *data2) |
Callback function used to determine of two values in a list are equal. | |
Functions | |
void | slist_free (SListEntry *list) |
Free an entire list. | |
SListEntry * | slist_prepend (SListEntry **list, void *data) |
Prepend data to the start of a list. | |
SListEntry * | slist_append (SListEntry **list, void *data) |
Append data to the end of a list. | |
SListEntry * | slist_next (SListEntry *listentry) |
Retrieve the next entry in a list. | |
void * | slist_data (SListEntry *listentry) |
Retrieve the data at a list entry. | |
SListEntry * | slist_nth_entry (SListEntry *list, int n) |
Retrieve the entry at a specified index in a list. | |
void * | slist_nth_data (SListEntry *list, int n) |
Retrieve the data at a specified entry in the list. | |
int | slist_length (SListEntry *list) |
Find the length of a list. | |
void ** | slist_to_array (SListEntry *list) |
Create a C array containing the contents of a list. | |
void | slist_foreach (SListEntry *list, SListIterator callback, void *user_data) |
Iterate over all entries in a list. | |
int | slist_remove_entry (SListEntry **list, SListEntry *entry) |
Remove an entry from a list. | |
int | slist_remove_data (SListEntry **list, SListEqualFunc callback, void *data) |
Remove all occurrences of a particular piece of data from a list. | |
void | slist_sort (SListEntry **list, SListCompareFunc compare_func) |
Sort a list. | |
SListEntry * | slist_find_data (SListEntry *list, SListEqualFunc callback, void *data) |
Find the entry for a particular data item in a list. |
A singly-linked list stores a collection of values. Each entry in the list (represented by a pointer to a SListEntry structure) contains a link to the next entry. It is only possible to iterate over entries in a singly linked list in one direction.
To create a new singly-linked list, create a variable which is a pointer to a SListEntry, and initialise it to NULL.
To destroy a singly linked list, use slist_free.
To add new data at the start of a list, use slist_prepend. To add new data at the end of a list, use slist_append.
To find the length of a list, use slist_length.
To access data in a list by its index in the list, use slist_nth_data.
To search a list for data, use slist_find_data.
To sort a list into an order, use slist_sort.
To iterate over a list, use slist_foreach.
To find a particular entry in a list by its index, use slist_nth_entry.
Given a particular entry in a list:
|
Callback function used to compare values in a list when sorting.
|
|
Represents an entry in a singly-linked list. The empty list is represented by a NULL pointer. To initialise a new singly linked list, simply create a variable of this type containing a pointer to NULL. |
|
Callback function used to determine of two values in a list are equal.
|
|
Append data to the end of a list.
|
|
Retrieve the data at a list entry.
|
|
Find the entry for a particular data item in a list.
|
|
Iterate over all entries in a list.
|
|
Free an entire list.
|
|
Find the length of a list.
|
|
Retrieve the next entry in a list.
|
|
Retrieve the data at a specified entry in the list.
|
|
Retrieve the entry at a specified index in a list.
|
|
Prepend data to the start of a list.
|
|
Remove all occurrences of a particular piece of data from a list.
|
|
Remove an entry from a list.
|
|
Sort a list.
|
|
Create a C array containing the contents of a list.
|