dbLkList.h File Reference

#include <stdio.h>
#include <stdlib.h>

Include dependency graph for dbLkList.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _DbLkListNodeContent
 each node in the list contains this struct More...
struct  _DbLkListNode
 a node in the list, has the content above and pointers to next and previous More...
struct  _DbLkList
 the list structure, holds pointer to tail and head, the number of elements, and callback functions More...

Typedefs

typedef _DbLkListListP
typedef void() ListVisitFunction (ListP, void *object)
typedef void() ListPrintFunction (ListP, void *object)
typedef void() ListDeleteFunction (ListP, void *object)
typedef _DbLkListNodeContent DbLkListNodeContent
 each node in the list contains this struct
typedef _DbLkListNode DbLkListNode
 a node in the list, has the content above and pointers to next and previous
typedef _DbLkList DbLkList
 the list structure, holds pointer to tail and head, the number of elements, and callback functions

Enumerations

enum  DbLkDestroyMode { DBLIST_DM_KEEP = 0, DBLIST_DM_FREE }
 this types indicates if we shall free contents More...
enum  DbLkTransMode { DBLIST_TM_FROM_HEAD, DBLIST_TM_FROM_TAIL }
 the way we shall transverse the list More...

Functions

DbLkListlistCreate ()
 Initializes the empty list.
void listDestroy (DbLkList **list, 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 **objectPointerAddress)
 Retrieves the object at the given position, but does not remove it from list.
int listRemoveObjectAt (DbLkList *list, int position, void **objectPointerAddress)
 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 listCat (DbLkList *destination, DbLkList **sourceAddress)
 Concatenates 2 list.
int listGetHead (DbLkList *list, void **objectAddress)
 Retrieves the first element in the list, ie, the head.
int listGetTail (DbLkList *list, void **objectAddress)
 Retrieves the first element in the list, ie, the head.
int listRemoveHead (DbLkList *list, void **object)
 Removes the list head, returning it at the object pointer argument.
int listRemoveTail (DbLkList *list, void **object)
 Removes the list tail, returning it at the object pointer argument.
void listRegisterPrintFunction (DbLkList *list, ListPrintFunction *printFunction)
 Registers a function to be called by the print function, in each list node.
void listPrint (DbLkList *list)
 Prints the list, from head to tail.
void listVisit (DbLkList *list)
 Visits the list, from head to tail, calling the registered function.
void listRegisterDeleteFunction (DbLkList *list, ListDeleteFunction *deleteFunction)
 Registers a function to be called by the destroy function, in each list node.


Typedef Documentation

typedef struct _DbLkList DbLkList
 

the list structure, holds pointer to tail and head, the number of elements, and callback functions

typedef struct _DbLkListNode DbLkListNode
 

a node in the list, has the content above and pointers to next and previous

typedef struct _DbLkListNodeContent DbLkListNodeContent
 

each node in the list contains this struct

typedef void() ListDeleteFunction(ListP, void *object)
 

Definition at line 30 of file dbLkList.h.

typedef struct _DbLkList* ListP
 

Definition at line 25 of file dbLkList.h.

typedef void() ListPrintFunction(ListP, void *object)
 

Definition at line 29 of file dbLkList.h.

typedef void() ListVisitFunction(ListP, void *object)
 

Definition at line 28 of file dbLkList.h.


Enumeration Type Documentation

enum DbLkDestroyMode
 

this types indicates if we shall free contents

Enumerator:
DBLIST_DM_KEEP 
DBLIST_DM_FREE 

Definition at line 18 of file dbLkList.h.

enum DbLkTransMode
 

the way we shall transverse the list

Enumerator:
DBLIST_TM_FROM_HEAD 
DBLIST_TM_FROM_TAIL 

Definition at line 23 of file dbLkList.h.


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.

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:20:01 2006 for Void by  doxygen 1.4.6