Main Page | Class List | File List | Class Members | File Members | Related Pages

list.h File Reference

Singly linked list routines. More...

Go to the source code of this file.

Classes

struct  listlink

Defines

#define list_next(n)   ((n) ? (n)->next : NULL)
#define list_prev(n)   ((n) ? (n)->prev : NULL)
#define LIST_FOREACH(func)   ((ListForeachFunc)func)

Typedefs

typedef int(* CompareFunc )(void *a, void *b)
typedef listlink List

Functions

LIBGIFT_EXPORT Listlist_append (List *head, void *udata)
LIBGIFT_EXPORT Listlist_prepend (List *head, void *udata)
LIBGIFT_EXPORT Listlist_insert (List *head, int nth, void *udata)
LIBGIFT_EXPORT Listlist_insert_sorted (List *head, CompareFunc func, void *udata)
LIBGIFT_EXPORT Listlist_remove (List *head, void *udata)
LIBGIFT_EXPORT Listlist_remove_link (List *head, List *link)
LIBGIFT_EXPORT Listlist_free (List *head)
LIBGIFT_EXPORT Listlist_find (List *head, void *udata)
LIBGIFT_EXPORT Listlist_find_custom (List *head, void *udata, CompareFunc func)
LIBGIFT_EXPORT void list_foreach (List *head, ListForeachFunc func, void *udata)
LIBGIFT_EXPORT Listlist_foreach_remove (List *head, ListForeachFunc func, void *udata)
LIBGIFT_EXPORT Listlist_nth (List *head, int nth)
LIBGIFT_EXPORT void * list_nth_data (List *head, int nth)
LIBGIFT_EXPORT Listlist_last (List *head)
LIBGIFT_EXPORT int list_length (List *head)
LIBGIFT_EXPORT Listlist_sort (List *head, CompareFunc func)
LIBGIFT_EXPORT Listlist_copy (List *head)

Variables

EXTERN_C_BEGIN typedef int(* ListForeachFunc )(void *data, void *udata)


Detailed Description

Singly linked list routines.

Implements a standard doubly linked list.


Typedef Documentation

typedef int(* CompareFunc)(void *a, void *b)
 

Node comparison.

Return values:
>0 a is greater than b
0 a is equal to b
<0 a is less than b

typedef struct listlink List
 

Linked list structure. This represents all chains in the list.


Function Documentation

LIBGIFT_EXPORT List* list_append List head,
void *  udata
 

Add a new link to the end of the linked list pointed to by `head'.

LIBGIFT_EXPORT List* list_copy List head  ) 
 

Allocate a copy of each individual node in the list decsribed by `head'. This will not affect the data added by the user.

LIBGIFT_EXPORT List* list_find List head,
void *  udata
 

Search for the first list link found with the user data element matching `udata'.

LIBGIFT_EXPORT List* list_find_custom List head,
void *  udata,
CompareFunc  func
 

Similar to list_find, except that comparison of your search data against the data in the list will be subject to the comparison function `func', instead of the default pointer comparison.

LIBGIFT_EXPORT void list_foreach List head,
ListForeachFunc  func,
void *  udata
 

Iterate through each node in the list described by `head' calling the iterator function `func' for each link chain encountered.

LIBGIFT_EXPORT List* list_foreach_remove List head,
ListForeachFunc  func,
void *  udata
 

Combination of list_foreach and list_free, allowing the user the chance to manage the memory of each individual link chain and the associated user data. See ListForeachFunc for more information on the various options you have.

LIBGIFT_EXPORT List* list_free List head  ) 
 

Walk through the list pointed to by `head' freeing each individual link pointer. This will not affect the data added by the user, which you will need to manage yourself. Consider list_foreach_remove for an alternate interface.

LIBGIFT_EXPORT List* list_insert List head,
int  nth,
void *  udata
 

Insert a new link immediately preceding the link that currently exists at the `nth' position.

LIBGIFT_EXPORT List* list_insert_sorted List head,
CompareFunc  func,
void *  udata
 

Similar to list_insert, but determines `nth' based on the result of the comparison function `func'.

LIBGIFT_EXPORT List* list_last List head  ) 
 

Iterate through the list described by `head' until the tail is reached, in which case it will be returned to the caller.

LIBGIFT_EXPORT int list_length List head  ) 
 

Determine the length of the list described by `head' through iteration.

LIBGIFT_EXPORT List* list_nth List head,
int  nth
 

Access the link chain at the nth position in the list described by `head'.

LIBGIFT_EXPORT void* list_nth_data List head,
int  nth
 

Similar to list_nth, except that the link chains user data element is returned instead of the link chain itself.

LIBGIFT_EXPORT List* list_prepend List head,
void *  udata
 

Similar to list_append, but uses the prepend operation.

LIBGIFT_EXPORT List* list_remove List head,
void *  udata
 

Search for and remove the element inserted with the data described by `udata'.

LIBGIFT_EXPORT List* list_remove_link List head,
List link
 

Similar to list_remove, but will not search for the links position. The memory pointed to by `link' will be freed by this call.

LIBGIFT_EXPORT List* list_sort List head,
CompareFunc  func
 

Sort the list described by `head' according to the comparison function `func'. If NULL is used for the comparison function, the default string comparison will be used via strcmp.


Variable Documentation

EXTERN_C_BEGIN typedef int(* ListForeachFunc)(void *data, void *udata)
 

Foreach iteration function. Return value depends on the usage.

Parameters:
data List data at this chain
udata Arbitrary data passed along


Generated on Sun Aug 22 08:07:11 2004 by doxygen 1.3.7