dbLkList.c File Reference

#include "dbLkList.h"

Include dependency graph for dbLkList.c:

Go to the source code of this file.

Functions

DbLkListlistCreate ()
 Initializes the empty list.
void listDestroy (DbLkList **listPointerAddress, DbLkDestroyMode mode)
 Destroys the list.
int listPrepare (DbLkList *list, DbLkTransMode from)
 prepares the list for itaration.
int listGetNext (DbLkList *list, void **object)
 get next node
int listGetPrevious (DbLkList *list, void **object)
 get previous node
int listInsertHead (DbLkList *list, void *object)
 Inserts an object in the list, as the new head node.
int listInsertTail (DbLkList *list, void *object)
 Inserts an object at the end of the list, as the new tail.
int listInsertAt (DbLkList *list, int position, void *object)
 Inserts the object at the given position.
int listGetObjectAt (DbLkList *list, int position, void **objectAddress)
 Retrieves the object at the given position, but does not remove it from list.
int listRemoveObjectAt (DbLkList *list, int position, void **objectAddress)
 Retrieves the object at the given position, removing it from list.
int listRemoveObject (DbLkList *list, void *object)
 Removes the given object from the list.
int listRemoveHead (DbLkList *list, void **objectAddress)
 Removes the list head, returning it at the object pointer argument.
int listRemoveTail (DbLkList *list, void **objectAddress)
 Removes the list tail, returning it at the object pointer argument.
int listGetTail (DbLkList *list, void **objectAddress)
 Retrieves the first element in the list, ie, the head.
int listGetHead (DbLkList *list, void **objectAddress)
 Retrieves the first element in the list, ie, the head.
int listCat (DbLkList *dest, DbLkList **sourceAddress)
 Concatenates 2 list.
void listVisit (DbLkList *list)
 Visits the list, from head to tail, calling the registered function.
void listPrint (DbLkList *list)
 Prints the list, from head to tail.
void listRegisterPrintFunction (DbLkList *list, ListPrintFunction *printFunction)
 Registers a function to be called by the print function, in each list node.
void listRegisterDeleteFunction (DbLkList *list, ListDeleteFunction *deleteFunction)
 Registers a function to be called by the destroy function, in each list node.
void listRegisterVisitFunction (DbLkList *list, ListVisitFunction *visitFunction)


Function Documentation

int listCat DbLkList destination,
DbLkList **  sourceAddress
 

Concatenates 2 list.

The source list is freed, the destination will hold all elements from the other. Source list is concatenated at the end of the destination

Parameters:
destination the destination list, which will hold all info from src
sourceAddress the address of the src list pointer, which will be NULL after this
Returns:
the number of elements of the destination list after concatenation, -1 if an error occurs

Definition at line 285 of file dbLkList.c.

References _DbLkList::head, _DbLkListNode::next, _DbLkList::numElements, _DbLkListNode::previous, and _DbLkList::tail.

DbLkList* listCreate  ) 
 

Initializes the empty list.

Returns:
the empty list, just created

Definition at line 87 of file dbLkList.c.

References _DbLkList::deleteFunction, _DbLkList::head, _DbLkList::lastVisited, _DbLkListNode::next, _DbLkList::numElements, _DbLkListNode::previous, _DbLkList::printFunction, _DbLkList::tail, and _DbLkList::visitFunction.

Referenced by stCreate(), and trcCreateData().

void listDestroy DbLkList **  list,
DbLkDestroyMode  mode
 

Destroys the list.

If theres a registered free function, it will be called for each node

Parameters:
list the address of the list pointer being destroyed. List pointer will be NULL after this
mode should the content be destroyed? If so, user function will get called, otherwise, a simple free is called on content

Definition at line 104 of file dbLkList.c.

References DBLIST_DM_FREE, _DbLkList::deleteFunction, listRemoveObjectAt(), and _DbLkList::numElements.

Referenced by stDestroy().

Here is the call graph for this function:

int listGetHead DbLkList list,
void **  objectAddress
 

Retrieves the first element in the list, ie, the head.

Does not remove from the list

Parameters:
list the list being searched
objectAddress the address of an object pointer, so we can return a pointer to the object
Returns:
1 if successful, -1 otherwise(empty list)

Definition at line 272 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::head, _DbLkListNode::next, _DbLkListNode::nodeContent, and _DbLkList::numElements.

int listGetNext DbLkList list,
void **  object
 

get next node

Returns:
-1 when pointer is at list last valid element, 1 otherwise

Definition at line 138 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::lastVisited, _DbLkListNode::next, _DbLkListNode::nodeContent, and _DbLkList::tail.

Referenced by stDestroy().

int listGetObjectAt DbLkList list,
int  position,
void **  objectPointerAddress
 

Retrieves the object at the given position, but does not remove it from list.

Parameters:
list the list being searched
position the position we are getting. 0 is the list head(first element).
objectPointerAddress the address of an object pointer, so we can return a pointer to the object
Returns:
1 if successful, -1 otherwise(ie, position does not exist)

Definition at line 200 of file dbLkList.c.

References _DbLkListNodeContent::content, and _DbLkListNode::nodeContent.

int listGetPrevious DbLkList list,
void **  object
 

get previous node

Returns:
-1 when pointer is at list first valid element, 1 otherwise

Definition at line 149 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::head, _DbLkList::lastVisited, _DbLkListNode::nodeContent, and _DbLkListNode::previous.

int listGetTail DbLkList list,
void **  objectAddress
 

Retrieves the first element in the list, ie, the head.

Does not remove from the list

Parameters:
list the list being searched
objectAddress the address of an object pointer, so we can return a pointer to the object
Returns:
1 if successful, -1 otherwise(empty list)

Definition at line 264 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkListNode::nodeContent, _DbLkList::numElements, _DbLkListNode::previous, and _DbLkList::tail.

Referenced by stGetTop().

int listInsertAt DbLkList list,
int  position,
void *  object
 

Inserts the object at the given position.

If position does not exist and is less than 0, it will be a head insertion. Else is a tail insertion.

Parameters:
list the list being inserted
position where the object will be inserted
object the object being inserted
Returns:
-1 on error, 1 otherwise

Definition at line 177 of file dbLkList.c.

References listInsertHead(), listInsertTail(), _DbLkList::numElements, and _DbLkListNode::previous.

Here is the call graph for this function:

int listInsertHead DbLkList list,
void *  object
 

Inserts an object in the list, as the new head node.

Parameters:
list the list being inserted
object the object being inserted
Returns:
-1 on error, 1 otherwise

Definition at line 168 of file dbLkList.c.

References _DbLkList::head.

Referenced by listInsertAt().

int listInsertTail DbLkList list,
void *  object
 

Inserts an object at the end of the list, as the new tail.

Parameters:
list the list being inserted
object the object being inserted
Returns:
-1 on error, 1 otherwise

Definition at line 172 of file dbLkList.c.

References _DbLkListNode::previous, and _DbLkList::tail.

Referenced by listInsertAt(), and stPush().

int listPrepare DbLkList list,
DbLkTransMode  from
 

prepares the list for itaration.

Should be called before getNext or getPrevious

Parameters:
list the list
from tail or head?
Returns:
-1 if list is empty, 1 otherwise

Definition at line 129 of file dbLkList.c.

References DBLIST_TM_FROM_HEAD, _DbLkList::head, _DbLkList::lastVisited, _DbLkList::numElements, and _DbLkList::tail.

Referenced by stDestroy().

void listPrint DbLkList list  ) 
 

Prints the list, from head to tail.

Parameters:
list the lsit being printed

Definition at line 326 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::head, _DbLkListNode::next, _DbLkListNode::nodeContent, _DbLkList::numElements, and _DbLkList::printFunction.

void listRegisterDeleteFunction DbLkList list,
ListDeleteFunction deleteFunction
 

Registers a function to be called by the destroy function, in each list node.

Parameters:
list the list
deleteFunction a function, of prototype ListPrintFunction

Definition at line 345 of file dbLkList.c.

References _DbLkList::deleteFunction.

void listRegisterPrintFunction DbLkList list,
ListPrintFunction printFunction
 

Registers a function to be called by the print function, in each list node.

If this function is not registered, calls to listVisit will return immediately.

Parameters:
list the list
visitFunction a function, of prototype ListVisitFunction

Definition at line 341 of file dbLkList.c.

References _DbLkList::printFunction.

void listRegisterVisitFunction DbLkList list,
ListVisitFunction visitFunction
 

Definition at line 349 of file dbLkList.c.

References _DbLkList::visitFunction.

int listRemoveHead DbLkList list,
void **  object
 

Removes the list head, returning it at the object pointer argument.

Returns:
1 if successful, -1 otherwise(list empty)

Definition at line 246 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::head, _DbLkListNode::next, _DbLkListNode::nodeContent, and _DbLkList::numElements.

Referenced by trcFlush().

int listRemoveObject DbLkList list,
void *  object
 

Removes the given object from the list.

Parameters:
list the list
object the object being removed
Returns:
1, -1 if object cant be found,

Definition at line 237 of file dbLkList.c.

int listRemoveObjectAt DbLkList list,
int  position,
void **  objectPointerAddress
 

Retrieves the object at the given position, removing it from list.

Parameters:
list the list being searched
position the position we are getting. 0 is the list head(first element).
objectPointerAddress the address of an object pointer, so we can return a pointer to the object
Returns:
1 if successful, -1 otherwise(ie, position does not exist)

Definition at line 224 of file dbLkList.c.

References _DbLkListNodeContent::content, and _DbLkListNode::nodeContent.

Referenced by listDestroy().

int listRemoveTail DbLkList list,
void **  object
 

Removes the list tail, returning it at the object pointer argument.

Returns:
1 if successful, -1 otherwise(list empty)

Definition at line 255 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkListNode::nodeContent, _DbLkList::numElements, _DbLkListNode::previous, and _DbLkList::tail.

Referenced by stPop().

void listVisit DbLkList list  ) 
 

Visits the list, from head to tail, calling the registered function.

If none, return.

Parameters:
list the list being printed

Definition at line 309 of file dbLkList.c.

References _DbLkListNodeContent::content, _DbLkList::head, _DbLkListNode::next, _DbLkListNode::nodeContent, _DbLkList::numElements, and _DbLkList::visitFunction.


Generated on Tue Jan 17 19:19:56 2006 for Void by  doxygen 1.4.6