Main Page | Data Structures | File List | Data Fields | Globals

llist.h File Reference

#include "cuf-global.h"

Go to the source code of this file.

Data Structures

struct  _LlistExtras
struct  _Llist

Defines

#define DEFAULT_PIVOT_THRESHOLD   20
#define lla(l, d)   l=llist_append (l, d)
#define llp(l, d)   l=llist_prepend (l, d)
#define llrm(l, d)   l=llist_remove (l, d)
#define llrmcf(l, d, cf)   l=llist_remove_cfunc (l, d, (CompareFunc)cf)
#define llrmop(l, d, op)   l=llist_remove_opfunc (l, d, (OperationFunc)op)
#define llrmcfop(l, d, cf, op)   l=llist_remove_cfunc_opfunc (l, d, (CompareFunc)cf, (OperationFunc)op)
#define llfree(l)   llist_free (l)
#define llfreeop(l, op)   llist_free_opfunc (l, (OperationFunc)op)
#define llnext(l)   llist_node_data_next (&l)
#define llprev(l)   llist_node_data_prev (&l)
#define llseekcf(l, d, cf)   llist_node_data_seek_cfunc (&l, d, (CompareFunc)cf)
#define llseekp(l, pos)   llist_node_data_seek_position (&l, pos)
#define llrise(l)   l=llist_data_rise (l, l->data)
#define llfall(l)   l=llist_data_fall (l, l->data)
#define llrew(l)   l=llist_rewind (l)
#define llff(l)   l=llist_fastforward (l)
#define llrev(l)   l=llist_reverse (l)
#define lllen(l)   llist_length (l)
#define llforeach(l, v)   for (v=llnext (l); v; v=llnext (l))
#define llforeachb(l, v, b)   for (v=llnext (l); v && b; v=llnext (l))

Typedefs

typedef _Llist Llist
typedef _LlistExtras LlistExtras

Functions

Llistllist_append (Llist *list, void *data)
Llistllist_prepend (Llist *list, void *data)
Llistllist_remove (Llist *list, void *data)
Llistllist_remove_cfunc (Llist *list, void *data, CompareFunc cfunc)
Llistllist_remove_opfunc (Llist *list, void *data, OperationFunc opfunc)
Llistllist_remove_cfunc_opfunc (Llist *list, void *data, CompareFunc cfunc, OperationFunc opfunc)
Llistllist_duplicate (Llist *orglist)
void llist_free (Llist *list)
void llist_free_opfunc (Llist *list, OperationFunc opfunc)
Llistllist_seek (Llist *list, void *data)
Llistllist_seek_cfunc (Llist *list, void *data, CompareFunc cfunc)
Llistllist_seek_position (Llist *list, unsigned long pos)
Llistllist_rewind (Llist *list)
Llistllist_fastforward (Llist *list)
Llistllist_reverse (Llist *list)
Llistllist_bubblesort (Llist *list, CompareFunc cfunc)
Llistllist_quicksort (Llist *list, CompareFunc cfunc)
Llistllist_data_rise (Llist *list, void *data)
Llistllist_data_fall (Llist *list, void *data)
void llist_autorewind_set (Llist *list, int autorewind)
void llist_default_autorewind_set (int autorewind)
void llist_pivot_threshold_set (Llist *list, int pivot_threshold)
unsigned long llist_length (Llist *list)
unsigned long llist_length_recalculate (Llist *list)
void llist_extras_print (Llist *list)


Detailed Description

A link list implementation v3.0

Define Documentation

#define DEFAULT_PIVOT_THRESHOLD   20
 

Description:
The default pivot threshold for llist_quicksort().

#define lla l,
 )     l=llist_append (l, d)
 

Parameters:
l The list to modify.
d The pointer to append.
Description:
Appends a data pointer to the linked list.
Note:
Their is no indication of failure if you run out of memory.

#define llfall  )     l=llist_data_fall (l, l->data)
 

Parameters:
l The node to move.
Description:
Moves the current node's data tward the end of the list by one node. If this is the last node nothing is done.

#define llff  )     l=llist_fastforward (l)
 

Parameters:
l The list to fastworward.
Description:
Fastforwards the list so as to point at the last node.

#define llforeach l,
 )     for (v=llnext (l); v; v=llnext (l))
 

Parameters:
l The list you want to traverse.
v the variable to assign the node data to.
Description:
Simplifyed for loop syntax to traverse a linked list.

Example Usage:

llforeach (mylist, string) { if (*string == '\0') continue; printf ("string=%s\n", string); }

#define llforeachb l,
v,
 )     for (v=llnext (l); v && b; v=llnext (l))
 

Parameters:
l The list you want to traverse.
v The variable to assign the node data to.
b The break condition.
Description:
Simplifyed for loop syntax to traverse a linked list. Like llforeach but allows you to specify extra break conditions.

Example Usage:

llforeachb (mylist, string, *string != 'A') { if (*string == '\0') continue; printf ("string=%s\n", string); }

#define llfree  )     llist_free (l)
 

Parameters:
l The list to free.
Description:
Frees a linked list and all the member nodes.

#define llfreeop l,
op   )     llist_free_opfunc (l, (OperationFunc)op)
 

Parameters:
l The list to modify.
op The operation function to call on each nodes data.
Description:
Frees a linked list and all the member nodes. The operation function is called on each nodes data as the node is removed.

#define lllen  )     llist_length (l)
 

Parameters:
l The list you want the number of nodes from.
Return values:
int With the number of nodes present in the list.
0 On error or NULL list.
Description:
Retrieves the number of nodes present in the linked list.

#define llnext  )     llist_node_data_next (&l)
 

Parameters:
l The list to traverse.
Return values:
void * Of the current nodes data.
NULL On list end or error.
Description:
Returns the data pointed to by the current node then increments the list one node.

#define llp l,
 )     l=llist_prepend (l, d)
 

Parameters:
l The list to modify.
d The pointer to append.
Description:
Prepends a data pointer to the linked list.
Note:
Their is no indication of failure if you run out of memory.

#define llprev  )     llist_node_data_prev (&l)
 

Parameters:
l The list to traverse.
Return values:
void * Of the current nodes data.
NULL On list beginning or error.
Description:
Returns the data pointed to by the current node then decrements the list one node.

#define llrev  )     l=llist_reverse (l)
 

Parameters:
l The list to reverse.
Description:
Reverses the contents order of the linked list.

#define llrew  )     l=llist_rewind (l)
 

Parameters:
l The list to rewind.
Description:
Rewinds the list so as to point at the first node.

#define llrise  )     l=llist_data_rise (l, l->data)
 

Parameters:
l The node to move.
Description:
Moves the current node's data tward the beginning of the list by one node. If this is the first node nothing is done.

#define llrm l,
 )     l=llist_remove (l, d)
 

Parameters:
l The list to modify.
d The pointer to remove.
Description:
Removes a data pointer from the linked list.

#define llrmcf l,
d,
cf   )     l=llist_remove_cfunc (l, d, (CompareFunc)cf)
 

Parameters:
l The list to modify.
d The pointer to compare.
cf The comparison function to call.
Description:
Removes a data pointer from the linked list using the comparison function to locate the data to be removed.

#define llrmcfop l,
d,
cf,
op   )     l=llist_remove_cfunc_opfunc (l, d, (CompareFunc)cf, (OperationFunc)op)
 

Parameters:
l The list to modify.
d The pointer to compare.
cf The comparison function to call.
op The operation function to call on the removed data.
Description:
Removes a data pointer from the linked list using the comparison function to locate the data to be removed. Then calling the operation function on the removed data.

#define llrmop l,
d,
op   )     l=llist_remove_opfunc (l, d, (OperationFunc)op)
 

Parameters:
l The list to modify.
d The pointer to remove.
op The operation function to call on the removed data.
Description:
Removes a data pointer from the linked list, then calling the operation function on the removed data.

#define llseekcf l,
d,
cf   )     llist_node_data_seek_cfunc (&l, d, (CompareFunc)cf)
 

Parameters:
l The list to seek in.
d The pointer to compare.
cf The comparison function to call.
Return values:
void * Of the found data.
NULL When no match is found or error.
Description:
Searches the linked list using the comparison function to locate the requested data and returns the found data pointer.

#define llseekp l,
pos   )     llist_node_data_seek_position (&l, pos)
 

Parameters:
l The list to seek in.
pos The desired posistion in the list.
Return values:
void * Of the found data.
NULL When no match is found or error.
Description:
Seeks to the n'th node in the list and returns its data pointer.


Typedef Documentation

typedef struct _Llist Llist
 

See also:
_Llist

typedef struct _LlistExtras LlistExtras
 

Description:
Linked list speedups, only to be modifyed internaly.


Function Documentation

Llist* llist_append Llist list,
void *  data
 

Parameters:
list The list to modify.
data The pointer to append.
Return values:
#Llist * Of the list, pointing to the new node.
NULL On 'out of memory' or error.
Description:
Appends a data pointer to the linked list.
Note:
Its recommended you use lla() instead unless you defiantly need error checking incase an 'out of memory' failure happens.

void llist_autorewind_set Llist list,
int  autorewind
 

Parameters:
list The list you want to update.
autorewind The new autorewind flag setting (TRUE or FALSE).
Description:
Set or Un-set the auto rewind flag. Set this flag if you want all modifying functions to return the first node in the list after their operation.
Note:
The list rewinding is O(1) and does not take up any processor time, this is purely preference.

Llist* llist_bubblesort Llist list,
CompareFunc  cfunc
 

Description:
Depreciated, please do not use this function for new programs, it will be phased out after llist_quicksort is concidered Rock Solid(tm).

Llist* llist_data_fall Llist list,
void *  data
 

Parameters:
list The linked list.
data The data pointer to move.
Description:
Moves the specifyed data pointer tward the end of the list by one node. If this is the last node nothing is done.
Note:
It is recomended you use llfall() instead of calling this function directly.

Llist* llist_data_rise Llist list,
void *  data
 

Parameters:
list The linked list.
data The data pointer to move.
Description:
Moves the specifyed data pointer tward the beginning of the list by one node. If this is the first node nothing is done.
Note:
It is recomended you use llrise() instead of calling this function directly.

void llist_default_autorewind_set int  autorewind  ) 
 

Parameters:
autorewind The default autorewind flag setting (TRUE or FALSE).
Description:
Set or Un-set the default auto rewind flag. This is simular to #llist_autorewind() except that this setting is used for all newly created lists. The default is TRUE.
Note:
The list rewinding is O(1) and does not take up any processor time, this is purely preference.

Llist* llist_duplicate Llist origlist  ) 
 

Parameters:
origlist The list to modify.
Return values:
#Llist * A newly allocated, duplicate list.
NULL On error.
Description:
Duplicates a linked list. Node order is maintained.

void llist_extras_print Llist list  ) 
 

Parameters:
list The list you want to display the extra info from.
Description:
Displays the LlistExtras attached to the supplied list.
Note:
This is only usefull for debugging internal llist functions.

Llist* llist_fastforward Llist list  ) 
 

Parameters:
list The list to fastworward.
Return values:
#Llist * Of the last node in the supplied list.
NULL On error.
Description:
Returns the last node in the suplied list.
Note:
It is recomended you use llff() instead of calling this function directly.

void llist_free Llist list  ) 
 

Parameters:
list The list to free.
Description:
Frees a list and all its member nodes.
Note:
It is recomended you use llfree() instead of calling this function directly.

void llist_free_opfunc Llist list,
OperationFunc  opfunc
 

Parameters:
list The list to free.
opfunc The operation function to call on each nodes data.
Description:
Frees a list and all the member nodes. The operation function is called on each nodes data as the node is removed.
Note:
It is recomended you use llfreeop() instead of calling this function directly.

unsigned long llist_length Llist list  ) 
 

Parameters:
list The list you want the number of nodes from.
Return values:
int With the number of nodes present in the list.
0 On error or NULL list.
Description:
Retrieves the number of nodes present in the linked list.
Note:
It is recomended you use lllen() instead of calling this function directly.

unsigned long llist_length_recalculate Llist list  ) 
 

Parameters:
list The list you want the number of nodes from.
Return values:
int With the number of nodes present in the list.
0 On error or NULL list.
Description:
Forcefully recalculates the number of nodes present in the list the updates internaly and returns the result.

void llist_pivot_threshold_set Llist list,
int  pivot_threshold
 

Parameters:
list The list you want to update.
pivot_threshold The new pivot threshold value.
Description:
Changes the default pivot threshold used when quick sorting. If you are not familiar with this term its best to leave it alone.

Llist* llist_prepend Llist list,
void *  data
 

Parameters:
list The list to modify.
data The pointer to append.
Return values:
#Llist * Of the list, pointing to the new node.
NULL On error.
Description:
Appends a data pointer to the linked list.
Note:
Its recommended you use llp() instead unless you defiantly need error checking incase an 'out of memory' failure happens.

Llist* llist_quicksort Llist list,
CompareFunc  cfunc
 

Parameters:
list The linked list to sort.
cfunc The comparison function
Return values:
#Llist * Of the sorted list.
NULL This should never be returned unless theirs a major bug.
Description:
Sorts the supplied linked list using the comparison function to determine the order of the data.
Note:
The Old list will likely be destroyed during the sort. If you wish to maintain a unsorted copy use llist_duplicate to back up the list before you use this function.

Llist* llist_remove Llist list,
void *  data
 

Parameters:
list The list to modify.
data The pointer to remove.
Return values:
#Llist * Of the list, pointing to the next or first node.
NULL When no more nodes are in the list or on error.
Description:
Removes a data pointer from the linked list.
Note:
Its recommended you use llrm() instead of calling this function directly.

Llist* llist_remove_cfunc Llist list,
void *  data,
CompareFunc  cfunc
 

Parameters:
list The list to modify.
data The pointer to compare.
cfunc The comparison function.
Return values:
#Llist * Of the list, pointing to the next or first node.
NULL When no more nodes are in the list or on error.
Description:
Removes a data pointer from the linked list useing the comparison function to locate the data to be removed.
Note:
Its recommended you use llrmcf() instead of calling this function directly.

Llist* llist_remove_cfunc_opfunc Llist list,
void *  data,
CompareFunc  cfunc,
OperationFunc  opfunc
 

Parameters:
list The list to modify.
data The pointer to compare.
cfunc The comparison function.
opfunc The operation function.
Return values:
#Llist * Of the list, pointing to the next or first node.
NULL When no more nodes are in the list or on error.
Description:
Removes a data pointer from the linked list useing the comparison function to locate the data to be removed. Then calling the operation function on the data to be removed.
Note:
Its recommended you use llrmcfop() instead of calling this function directly.

Llist* llist_remove_opfunc Llist list,
void *  data,
OperationFunc  opfunc
 

Parameters:
list The list to modify.
data The pointer to remove.
opfunc The operation function.
Return values:
#Llist * Of the list, pointing to the next or first node.
NULL When no more nodes are in the list or on error.
Description:
Removes a data pointer from the linked, then calling the operation function on the data to be removed.
Note:
Its recommended you use llrmop() instead of calling this function directly.

Llist* llist_reverse Llist list  ) 
 

Parameters:
list The list to reverse.
Return values:
#Llist * Of the first node in the recorded list.
NULL On error.
Description:
Reverses the contents order of the linked list.
Note:
It is recomended you use llrev() instead of calling this function directly.

Llist* llist_rewind Llist list  ) 
 

Parameters:
list The list to rewind.
Return values:
#Llist * Of the first node in the suplied list.
NULL On error.
Description:
Returns the first node in the supplied list.
Note:
It is recomended you use llrew() instead of calling this function directly.

Llist* llist_seek Llist list,
void *  data
 

Parameters:
list The list to seek through.
data The data pointer to search for.
Return values:
#Llist * The node containing the found data pointer.
NULL When no match is found or error.
Description:
Searches a linked list for the data pointer supplied.
Note:
Not a very usefull function.

Llist* llist_seek_cfunc Llist list,
void *  data,
CompareFunc  cfunc
 

Parameters:
list The list to seek in.
data The pointer to compare.
cfunc The comparison function to call.
Return values:
#Llist * The node containing the found data pointer.
NULL When no match is found or error.
Description:
Searches the linked list using the comparison function to locate the requested data and returns the node containing the found data pointer.
Note:
It is recomended you use llseekcf() instead of calling this function directly.

Llist* llist_seek_position Llist list,
unsigned long  pos
 

Parameters:
list The list to seek in.
pos The desired posistion in the list.
Return values:
#Llist * Of the node containing found data pointer.
NULL When no match is found or error.
Description:
Seeks to the n'th node in the list and returns the node containing the requested data pointer.
Note:
It is recomended you use llseekp() instead of calling this function directly.


Generated on Fri Jun 4 18:35:19 2004 for cuf by doxygen 1.3.6