Typedefs | |
typedef _ListEntry | ListEntry |
Represents an entry in a doubly-linked list. | |
typedef void(* | ListIterator )(void *data, void *user_data) |
Callback function used for iterating over a list. | |
typedef int(* | ListCompareFunc )(void *data1, void *data2) |
Callback function used to compare values in a list when sorting. | |
typedef int(* | ListEqualFunc )(void *data1, void *data2) |
Callback function used to determine of two values in a list are equal. | |
Functions | |
void | list_free (ListEntry *list) |
Free an entire list. | |
ListEntry * | list_prepend (ListEntry **list, void *data) |
Prepend data to the start of a list. | |
ListEntry * | list_append (ListEntry **list, void *data) |
Append data to the end of a list. | |
ListEntry * | list_prev (ListEntry *listentry) |
Retrieve the previous entry in a list. | |
ListEntry * | list_next (ListEntry *listentry) |
Retrieve the next entry in a list. | |
void * | list_data (ListEntry *listentry) |
Retrieve the data at a list entry. | |
ListEntry * | list_nth_entry (ListEntry *list, int n) |
Retrieve the entry at a specified index in a list. | |
void * | list_nth_data (ListEntry *list, int n) |
Retrieve the data at a specified entry in the list. | |
int | list_length (ListEntry *list) |
Find the length of a list. | |
void ** | list_to_array (ListEntry *list) |
Create a C array containing the contents of a list. | |
void | list_foreach (ListEntry *list, ListIterator callback, void *user_data) |
Iterate over all entries in a list. | |
int | list_remove_entry (ListEntry **list, ListEntry *entry) |
Remove an entry from a list. | |
int | list_remove_data (ListEntry **list, ListEqualFunc callback, void *data) |
Remove all occurrences of a particular piece of data from a list. | |
void | list_sort (ListEntry **list, ListCompareFunc compare_func) |
Sort a list. | |
ListEntry * | list_find_data (ListEntry *list, ListEqualFunc callback, void *data) |
Find the entry for a particular data item in a list. |
A doubly-linked list stores a collection of values. Each entry in the list (represented by a pointer a ListEntry structure) contains a link to the next entry and the previous entry. It is therefore possible to iterate over entries in the list in either direction.
To create an empty list, create a new variable which is a pointer to a ListEntry structure, and initialise it to NULL. To destroy an entire list, use list_free.
To add data to a list, use list_append or list_prepend.
To remove data from a list, use list_remove_entry or list_remove_data.
To iterate over entries in a list, use list_next and list_prev, along with the list_data function to access data.
To access an entry in the list by index, use list_nth_entry or list_nth_data.
To sort a list, use list_sort.
|
Callback function used to compare values in a list when sorting.
|
|
Represents an entry in a doubly-linked list. The empty list is represented by a NULL pointer. To initialise a new doubly 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.
|
|
Callback function used for iterating over a list.
|
|
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.
|
|
Retrieve the previous entry in 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.
|