Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members  

Linked List Routines

Linked List ADT (Abstract Data Type :). More...

Compounds

struct  psList
struct  psListNode

Typedefs

typedef struct psListNode  PSListNode
 Typedef for psListNode structure.

typedef struct psList  PSList
 Typedef for psList structure.


Functions

PSList* psListAlloc (PSListDestroyFunc destroyFunc)
 Allocates and initializes a new PSList. More...

void psListFree (PSList *list)
 Frees up a PSList. More...

PSListNodepsListInsert (PSList *list, PSListNode *node, void *value)
 Creates and inserts a new PSListNode into list in front of node. More...

void psListDelete (PSList *list, PSListNode *node)
 Deletes the specifed node (and data) from list. More...

PSListNodepsListFirst (PSList *list)
 Gets the first node in list. More...

PSListNodepsListLast (PSList *list)
 Gets the last node in list. More...

PSListNodepsListNext (PSList *list, PSListNode *node)
 Gets the next node (following node) in list. More...

PSListNodepsListPrev (PSList *list, PSListNode *node)
 Gets the previous node (before node) in list. More...

long psListNumNodes (PSList *list)
 Gets the number of nodes (items) in list. More...

void* psListGetValue (PSList *list, PSListNode *node)
 Gets the value stored in list at node. More...

PSListNodepsListGetNode (PSList *list, long nodeNum)
 Get the nodeNum'th node in list. More...


Detailed Description

Linked List ADT (Abstract Data Type :).


Function Documentation

PSList * psListAlloc ( PSListDestroyFunc destroyFunc )
 

Allocates and initializes a new PSList.

Parameters:
destroyFunc   pointer to a function to destroy/free the data to be stored in the list. May be set to NULL to indicate that the data should not be destroyed (i.e. the list doesn't own the data or items are statically allocated, etc.).

Returns:
a pointer to a new PSList on success or NULL on failure.
See also:
psListFree().

void psListDelete ( PSList * list,
PSListNode * node )
 

Deletes the specifed node (and data) from list.

Calls the destroyFunc on the data if not NULL.

Parameters:
list   pointer to PSList.
node   pointer to node to delete.

Returns:
nothing.

PSListNode * psListFirst ( PSList * list )
 

Gets the first node in list.

Parameters:
list   pointer to PSList.

Returns:
a pointer to the first node in list if the list has a first node or NULL if not (the list is empty).

void psListFree ( PSList * list )
 

Frees up a PSList.

Calls the destroyFunc on each piece of data if not NULL.

Parameters:
list   pointer to PSList to be freed.
Returns:
nothing.
See also:
psListAlloc().

PSListNode * psListGetNode ( PSList * list,
long nodeNum )
 

Get the nodeNum'th node in list.

Returns:
a pointer to the nodeNum'th node in list or NULL if the node doesn't exist.

void * psListGetValue ( PSList * list,
PSListNode * node )
 

Gets the value stored in list at node.

Parameters:
list   pointer to PSList.
node   pointer to node from which to retieve data.

Returns:
the data stored in the specified node.

PSListNode * psListInsert ( PSList * list,
PSListNode * node,
void * value )
 

Creates and inserts a new PSListNode into list in front of node.

Parameters:
list   pointer to PSList in which to insert node.
node   pointer to node to insert in front of.
value   pointer to data to be stored.

Returns:
a pointer to the new node on success or NULL on failure.

PSListNode * psListLast ( PSList * list )
 

Gets the last node in list.

Parameters:
list   pointer to PSList.

Returns:
a pointer to the last node in list if the list has a last node or NULL if not (the list is empty).

PSListNode * psListNext ( PSList * list,
PSListNode * node )
 

Gets the next node (following node) in list.

Parameters:
list   pointer to PSList.
node   pointer to node.

Returns:
A pointer to the node following node if one exists or NULL if not (end of list).

long psListNumNodes ( PSList * list )
 

Gets the number of nodes (items) in list.

Parameters:
list   pointer to PSList.

Returns:
the number of items in list.

PSListNode * psListPrev ( PSList * list,
PSListNode * node )
 

Gets the previous node (before node) in list.

Parameters:
list   pointer to PSList.
node   pointer to node.

Returns:
A pointer to the node previous to node if one exists or NULL if not (beginning of list).


Generated at Mon Dec 11 22:46:31 2000 for Postscript Utility Library by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000