LinkedList.c File Reference

functions which apply to linked list structures. More...

#include "LinkedList.h"
#include <stdlib.h>
#include <string.h>
#include "Heap.h"
Include dependency graph for LinkedList.c:

Functions

static int ListUnlink (List *aList, void *content, int(*callback)(void *, void *), int freeContent)
 Removes and optionally frees an element in a list by comparing the content.
void ListZero (List *newl)
 Sets a list structure to empty - all null values.
ListListInitialize (void)
 Allocates and initializes a new list structure.
void ListAppendNoMalloc (List *aList, void *content, ListElement *newel, size_t size)
 Append an already allocated ListElement and content to a list.
void ListAppend (List *aList, void *content, size_t size)
 Append an item to a list.
void ListInsert (List *aList, void *content, size_t size, ListElement *index)
 Insert an item to a list at a specific position.
ListElementListFind (List *aList, void *content)
 Finds an element in a list by comparing the content pointers, rather than the contents.
ListElementListFindItem (List *aList, void *content, int(*callback)(void *, void *))
 Finds an element in a list by comparing the content or pointer to the content.
int ListDetach (List *aList, void *content)
 Removes but does not free an item in a list by comparing the pointer to the content.
int ListRemove (List *aList, void *content)
 Removes and frees an item in a list by comparing the pointer to the content.
void * ListDetachHead (List *aList)
 Removes and frees an the first item in a list.
int ListRemoveHead (List *aList)
 Removes and frees an the first item in a list.
void * ListPopTail (List *aList)
 Removes but does not free the last item in a list.
int ListDetachItem (List *aList, void *content, int(*callback)(void *, void *))
 Removes but does not free an element in a list by comparing the content.
int ListRemoveItem (List *aList, void *content, int(*callback)(void *, void *))
 Removes and frees an element in a list by comparing the content.
void ListEmpty (List *aList)
 Removes and frees all items in a list, leaving the list ready for new items.
void ListFree (List *aList)
 Removes and frees all items in a list, and frees the list itself.
void ListFreeNoContent (List *aList)
 Removes and but does not free all items in a list, and frees the list itself.
ListElementListNextElement (List *aList, ListElement **pos)
 Forward iteration through a list.
ListElementListPrevElement (List *aList, ListElement **pos)
 Backward iteration through a list.
int intcompare (void *a, void *b)
 List callback function for comparing integers.
int stringcompare (void *a, void *b)
 List callback function for comparing C strings.

Detailed Description

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.


Function Documentation

int intcompare ( void *  a,
void *  b 
)

List callback function for comparing integers.

Parameters:
a first integer value
b second integer value
Returns:
boolean indicating whether a and b are equal
void ListAppend ( List aList,
void *  content,
size_t  size 
)

Append an item to a list.

Parameters:
aList the list to which the item is to be added
content the list item content itself
size the size of the element

Here is the call graph for this function:

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:
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
int ListDetach ( List aList,
void *  content 
)

Removes but does not free an item in a list by comparing the pointer to the content.

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

Here is the call graph for this function:

void* ListDetachHead ( List aList  ) 

Removes and frees an the first item in a list.

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

Here is the call graph for this function:

void ListEmpty ( List aList  ) 

Removes and frees all items in a list, leaving the list ready for new items.

Parameters:
aList the list to which the operation is to be applied
ListElement* ListFind ( List aList,
void *  content 
)

Finds an element in a list by comparing the content pointers, rather than the contents.

Parameters:
aList the list in which the search is to be conducted
content pointer to the list item content itself
Returns:
the list item found, or NULL

Here is the call graph for this function:

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:
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)
Returns:
the list element found, or NULL

Here is the call graph for this function:

void ListFree ( List aList  ) 

Removes and frees all items in a list, and frees the list itself.

Parameters:
aList the list to which the operation is to be applied

Here is the call graph for this function:

void ListFreeNoContent ( List aList  ) 

Removes and but does not free all items in a list, and frees the list itself.

Parameters:
aList the list to which the operation is to be applied
List* ListInitialize ( void   ) 

Allocates and initializes a new list structure.

Returns:
a pointer to the new list structure

Here is the call graph for this function:

void ListInsert ( List aList,
void *  content,
size_t  size,
ListElement index 
)

Insert an item to a list at a specific position.

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

Here is the call graph for this function:

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

Forward iteration through a list.

Parameters:
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
Returns:
pointer to the current list element
void* ListPopTail ( List aList  ) 

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

Parameters:
aList the list from which the item is to be removed
Returns:
the last item removed (or NULL if none was)
ListElement* ListPrevElement ( List aList,
ListElement **  pos 
)

Backward iteration through a list.

Parameters:
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
Returns:
pointer to the current list element
int ListRemove ( List aList,
void *  content 
)

Removes and frees an item in a list by comparing the pointer to the content.

Parameters:
aList the list from which the item is to be removed
content pointer to the content to look for
Returns:
1=item removed, 0=item not removed

Here is the call graph for this function:

int ListRemoveHead ( List aList  ) 

Removes and frees an the first item in a list.

Parameters:
aList the list from which the item is to be removed
Returns:
1=item removed, 0=item not removed

Here is the call graph for this function:

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:
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
Returns:
1=item removed, 0=item not removed

Here is the call graph for this function:

static int ListUnlink ( List aList,
void *  content,
int(*)(void *, void *)  callback,
int  freeContent 
) [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.

Parameters:
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
Returns:
1=item removed, 0=item not removed

Here is the call graph for this function:

void ListZero ( List newl  ) 

Sets a list structure to empty - all null values.

Does not remove any items from the list.

Parameters:
newl a pointer to the list structure to be initialized
int stringcompare ( void *  a,
void *  b 
)

List callback function for comparing C strings.

Parameters:
a first integer value
b second integer value
Returns:
boolean indicating whether a and b are equal
 All Data Structures Files Functions Variables Typedefs Defines

Generated on 2 Jun 2018 for MQTT C Client Libraries Internals by  doxygen 1.6.1