Classes | Typedefs | Functions
LinkedList.h File Reference
#include <stdlib.h>
Include dependency graph for LinkedList.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  List
 
struct  ListElementStruct
 

Typedefs

typedef struct ListElementStruct ListElement
 

Functions

int intcompare (void *a, void *b)
 
ListElementListAppend (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)
 
ListElementListFind (List *aList, void *content)
 
ListElementListFindItem (List *aList, void *content, int(*callback)(void *, void *))
 
void ListFree (List *aList)
 
void ListFreeNoContent (List *aList)
 
ListListInitialize (void)
 
ListElementListInsert (List *aList, void *content, size_t size, ListElement *index)
 
ListElementListNextElement (List *aList, ListElement **pos)
 
void * ListPopTail (List *aList)
 
ListElementListPrevElement (List *aList, ListElement **pos)
 
int ListRemove (List *aList, void *content)
 
int ListRemoveHead (List *aList)
 
int ListRemoveItem (List *aList, void *content, int(*callback)(void *, void *))
 
void ListZero (List *)
 
int stringcompare (void *a, void *b)
 

Typedef Documentation

Structure to hold all data for one list element

Function Documentation

int intcompare ( void *  a,
void *  b 
)

List callback function for comparing integers

Parameters
afirst integer value
bsecond integer value
Returns
boolean indicating whether a and b are equal

Definition at line 436 of file LinkedList.c.

ListElement* ListAppend ( List aList,
void *  content,
size_t  size 
)

Append an item to a list.

Parameters
aListthe list to which the item is to be added
contentthe list item content itself
sizethe 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.

Parameters
aListthe list to which the item is to be added
contentthe list item content itself
newelthe ListElement to be used in adding the new item
sizethe 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.

Parameters
aListthe list in which the search is to be conducted
contentpointer to the content to look for
Returns
1=item removed, 0=item not removed

Definition at line 245 of file LinkedList.c.

void* ListDetachHead ( List aList)

Removes and frees an the first item in a list.

Parameters
aListthe list from which the item is to be removed
Returns
1=item removed, 0=item not 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.

Parameters
aListthe list in which the search is to be conducted
contentpointer to the content to look for
callbackpointer to a function which compares each element
Returns
1=item removed, 0=item not removed

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.

Parameters
aListthe 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

Parameters
aListthe list in which the search is to be conducted
contentpointer to the list item content itself
Returns
the list item found, or NULL

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.

Parameters
aListthe list in which the search is to be conducted
contentpointer to the content to look for
callbackpointer to a function which compares each element (NULL means compare by content pointer)
Returns
the list element found, or NULL

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

Parameters
aListthe 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

Parameters
aListthe 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.

Returns
a pointer to the 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.

Parameters
aListthe list to which the item is to be added
contentthe list item content itself
sizethe size of the element
indexthe 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

Parameters
aListthe list to which the operation is to be applied
pospointer 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
Returns
pointer to the current list element

Definition at line 411 of file LinkedList.c.

void* ListPopTail ( List aList)

Removes but does not free the last item in a list.

Parameters
aListthe list from which the item is to be removed
Returns
the last item removed (or NULL if none was)

Definition at line 306 of file LinkedList.c.

ListElement* ListPrevElement ( List aList,
ListElement **  pos 
)

Backward iteration through a list

Parameters
aListthe list to which the operation is to be applied
pospointer 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
Returns
pointer to the current list element

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.

Parameters
aListthe list from which the item is to be removed
contentpointer to the content to look for
Returns
1=item removed, 0=item not removed

Definition at line 257 of file LinkedList.c.

int ListRemoveHead ( List aList)

Removes and frees an the first item in a list.

Parameters
aListthe list from which the item is to be removed
Returns
1=item removed, 0=item not 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

Parameters
aListthe list in which the search is to be conducted
contentpointer to the content to look for
callbackpointer to a function which compares each element
Returns
1=item removed, 0=item not removed

Definition at line 349 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.

Parameters
newla 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

Parameters
afirst integer value
bsecond integer value
Returns
boolean indicating whether a and b are equal

Definition at line 448 of file LinkedList.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:48