functions which apply to linked list structures. More...
Go to the source code of this file.
Functions | |
int | intcompare (void *a, void *b) |
ListElement * | ListAppend (List *aList, void *content, size_t size) |
void | ListAppendNoMalloc (List *aList, void *content, ListElement *newel, size_t size) |
int | ListDetach (List *aList, void *content) |
void * | ListDetachHead (List *aList) |
int | ListDetachItem (List *aList, void *content, int(*callback)(void *, void *)) |
void | ListEmpty (List *aList) |
ListElement * | ListFind (List *aList, void *content) |
ListElement * | ListFindItem (List *aList, void *content, int(*callback)(void *, void *)) |
void | ListFree (List *aList) |
void | ListFreeNoContent (List *aList) |
List * | ListInitialize (void) |
ListElement * | ListInsert (List *aList, void *content, size_t size, ListElement *index) |
ListElement * | ListNextElement (List *aList, ListElement **pos) |
void * | ListPopTail (List *aList) |
ListElement * | ListPrevElement (List *aList, ListElement **pos) |
int | ListRemove (List *aList, void *content) |
int | ListRemoveHead (List *aList) |
int | ListRemoveItem (List *aList, void *content, int(*callback)(void *, void *)) |
static int | ListUnlink (List *aList, void *content, int(*callback)(void *, void *), int freeContent) |
void | ListZero (List *newl) |
int | stringcompare (void *a, void *b) |
functions which apply to linked list structures.
These linked lists can hold data of any sort, pointed to by the content pointer of the ListElement structure. ListElements hold the points to the next and previous items in the list.
Definition in file LinkedList.c.
int intcompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing integers
a | first integer value |
b | second integer value |
Definition at line 436 of file LinkedList.c.
ListElement* ListAppend | ( | List * | aList, |
void * | content, | ||
size_t | size | ||
) |
Append an item to a list.
aList | the list to which the item is to be added |
content | the list item content itself |
size | the size of the element |
Definition at line 90 of file LinkedList.c.
void ListAppendNoMalloc | ( | List * | aList, |
void * | content, | ||
ListElement * | newel, | ||
size_t | size | ||
) |
Append an already allocated ListElement and content to a list. Can be used to move an item from one list to another.
aList | the list to which the item is to be added |
content | the list item content itself |
newel | the ListElement to be used in adding the new item |
size | the size of the element |
Definition at line 69 of file LinkedList.c.
int ListDetach | ( | List * | aList, |
void * | content | ||
) |
Removes but does not free an item in a list by comparing the pointer to the content.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
Definition at line 245 of file LinkedList.c.
void* ListDetachHead | ( | List * | aList | ) |
Removes and frees an the first item in a list.
aList | the list from which the item is to be removed |
Definition at line 268 of file LinkedList.c.
int ListDetachItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Removes but does not free an element in a list by comparing the content. A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
Definition at line 335 of file LinkedList.c.
void ListEmpty | ( | List * | aList | ) |
Removes and frees all items in a list, leaving the list ready for new items.
aList | the list to which the operation is to be applied |
Definition at line 359 of file LinkedList.c.
ListElement* ListFind | ( | List * | aList, |
void * | content | ||
) |
Finds an element in a list by comparing the content pointers, rather than the contents
aList | the list in which the search is to be conducted |
content | pointer to the list item content itself |
Definition at line 140 of file LinkedList.c.
ListElement* ListFindItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Finds an element in a list by comparing the content or pointer to the content. A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element (NULL means compare by content pointer) |
Definition at line 154 of file LinkedList.c.
void ListFree | ( | List * | aList | ) |
Removes and frees all items in a list, and frees the list itself
aList | the list to which the operation is to be applied |
Definition at line 381 of file LinkedList.c.
void ListFreeNoContent | ( | List * | aList | ) |
Removes and but does not free all items in a list, and frees the list itself
aList | the list to which the operation is to be applied |
Definition at line 392 of file LinkedList.c.
List* ListInitialize | ( | void | ) |
Allocates and initializes a new list structure.
Definition at line 52 of file LinkedList.c.
ListElement* ListInsert | ( | List * | aList, |
void * | content, | ||
size_t | size, | ||
ListElement * | index | ||
) |
Insert an item to a list at a specific position.
aList | the list to which the item is to be added |
content | the list item content itself |
size | the size of the element |
index | the position in the list. If NULL, this function is equivalent to ListAppend. |
Definition at line 107 of file LinkedList.c.
ListElement* ListNextElement | ( | List * | aList, |
ListElement ** | pos | ||
) |
Forward iteration through a list
aList | the list to which the operation is to be applied |
pos | pointer to the current position in the list. NULL means start from the beginning of the list This is updated on return to the same value as that returned from this function |
Definition at line 411 of file LinkedList.c.
void* ListPopTail | ( | List * | aList | ) |
Removes but does not free the last item in a list.
aList | the list from which the item is to be removed |
Definition at line 306 of file LinkedList.c.
ListElement* ListPrevElement | ( | List * | aList, |
ListElement ** | pos | ||
) |
Backward iteration through a list
aList | the list to which the operation is to be applied |
pos | pointer to the current position in the list. NULL means start from the end of the list This is updated on return to the same value as that returned from this function |
Definition at line 424 of file LinkedList.c.
int ListRemove | ( | List * | aList, |
void * | content | ||
) |
Removes and frees an item in a list by comparing the pointer to the content.
aList | the list from which the item is to be removed |
content | pointer to the content to look for |
Definition at line 257 of file LinkedList.c.
int ListRemoveHead | ( | List * | aList | ) |
Removes and frees an the first item in a list.
aList | the list from which the item is to be removed |
Definition at line 294 of file LinkedList.c.
int ListRemoveItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Removes and frees an element in a list by comparing the content. A callback function is used to define the method of comparison for each element
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
Definition at line 349 of file LinkedList.c.
|
static |
Removes and optionally frees an element in a list by comparing the content. A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
freeContent | boolean value to indicate whether the item found is to be freed |
Definition at line 201 of file LinkedList.c.
void ListZero | ( | List * | newl | ) |
Sets a list structure to empty - all null values. Does not remove any items from the list.
newl | a pointer to the list structure to be initialized |
Definition at line 42 of file LinkedList.c.
int stringcompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing C strings
a | first integer value |
b | second integer value |
Definition at line 448 of file LinkedList.c.