Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

mlist_tmpl_h.inc File Reference

data type independent list template (header). More...

#include "common.h"
#include "tmpl_common.h"

Include dependency graph for mlist_tmpl_h.inc:

Include dependency graph

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

Included by dependency graph

Go to the source code of this file.

Defines

#define MLPFX   ML_FUNC_PFX
 define a convenient abbreviation for the macro containing the current lists function name prefix.


Typedefs

typedef ML_LIST_NAME * ML_LIST_NAME
 hide the data types true nature from the user.


Functions

ML_LIST_NAME ml_pfx_Init ()
 initialises a new instance of a list object. More...

ML_LIST_NAME ml_pfx_Dublicate (ML_LIST_NAME liste)
 copies a list object, including the stored data. More...

ML_LIST_NAME ml_pfx_Clone (ML_LIST_NAME liste)
 clones a list object (dependant clone). More...

int ml_pfx_InsertAfter (ML_LIST_NAME liste, MlCargo new_load)
 inserts a new node after the current one into the list. More...

int ml_pfx_InsertBefore (ML_LIST_NAME liste, MlCargo new_load)
 inserts a new node in front of the current one into the list. More...

void ml_pfx_Append (ML_LIST_NAME liste, MlCargo new_load)
 appends a new node to the end of the list. More...

void ml_pfx_Prepend (ML_LIST_NAME liste, MlCargo new_load)
 prepends a new node to the beginning of the list. More...

int ml_pfx_Delete (ML_LIST_NAME liste)
 deletes the "current" node from the list. More...

void ml_pfx_Next (ML_LIST_NAME liste)
 selects the node after the currently selected node. More...

void ml_pfx_Prev (ML_LIST_NAME liste)
 selects the node in front of the currently selected node. More...

void ml_pfx_First (ML_LIST_NAME liste)
 selects the first node as the "current" one. More...

void ml_pfx_Last (ML_LIST_NAME liste)
 selects the last node as the "current" one. More...

int ml_pfx_SetPayload (ML_LIST_NAME liste, MlCargo new_load)
 sets the current node's payload value. More...

MlCargo ml_pfx_GetPayload (ML_LIST_NAME liste)
 returns the current node's payload value. More...

int ml_pfx_IsEmpty (ML_LIST_NAME liste)
 returns true if the list is empty. More...

int ml_pfx_IsHead (ML_LIST_NAME liste)
 returns true if the current node is the list's head. More...

int ml_pfx_IsTail (ML_LIST_NAME liste)
 returns true if the current node is the list's tail. More...

int ml_pfx_IsValid (ML_LIST_NAME liste)
 returns true if the current node is invalid (that is, head or tail). More...

int ml_pfx_IsValidValue (MlCargo load)
 returns true if the given MlCargo does not equal ML_INVALID. More...

int ml_pfx_Terminate (ML_LIST_NAME liste)
 frees all ressources allocated by the list (complementary function to list_prfx_Init()). More...


Detailed Description

data type independent list template (header).

This module contains a data type independant doubly linked list template. It can easily be customized for new data types by defining ML_LIST_NAME, which becomes the name of the new list "class", ML_FUNC_PFX, which is prepended to all function names listed below, and MlCargo which must expand to the actual data type to be stored in the list.

This can be done using a tiny adapter file, see chrlist.[ch] for an example.
All adapted list classes will benefit automatically and without any modification from bug fixes, improvements or new functions in this template.

Please refer to the detailed documentation in mlist_tmpl_c.inc if you * play to write or customize your own mlist_tmpl adapter. *

Definition in file mlist_tmpl_h.inc.


Function Documentation

void ml_pfx_Append ML_LIST_NAME    liste,
MlCargo    new_load
 

appends a new node to the end of the list.

<prefix>Append creates a new node and appends it to the end of the list. It's payload value is set to "new_load", which must be of the appropriate data type for this list. The new node is selected as the new "current node".

Parameters:
liste  a list object
new_load  data to store in the new node

ML_LIST_NAME ml_pfx_Clone ML_LIST_NAME    liste
 

clones a list object (dependant clone).

<prefix>Clone clones an already existing list object. The clone will have its own current list node but accesses and operates on the same list content. IT DOES NOT COPY the list's content so you should NOT modify the structure (add/remove elements) of a list that has been cloned. Changing a list node's contents within a list that has been cloned is okay as long as you're not using it in different threads. (mlist isn't thread-safe jet anyway, so that doesn't matter much...)

Returns:
returns a clone of the list object liste

int ml_pfx_Delete ML_LIST_NAME    liste
 

deletes the "current" node from the list.

<prefix>Delete removes the node selected as the current node from the list (given it's not the list's head, tail or an invalid node) and frees its associated memory. The node after the deleted node becomes the new "current node".

Parameters:
liste  a list object
Returns:
returns 0 on success and -1 if the current node cannot be deleted

ML_LIST_NAME ml_pfx_Dublicate ML_LIST_NAME    liste
 

copies a list object, including the stored data.

<prefix>Dublicate dublicates an entire already existing list object. The dublicated list will be totally independant from its ancestor and will be in the same state (current node, etc). The state of the original list is not changed. NOTE: If the list you dublicate is a list storing pointers, the actual data in the list will NOT be dublicated, only the pinters will.

Returns:
returns an independant copy of the list object liste

void ml_pfx_First ML_LIST_NAME    liste
 

selects the first node as the "current" one.

<prefix>First makes the first node of the list the "current" node. If the list is empty, the list's tail (!!!) is selected, that is, the "current" node gets invalid and <prefix>IsTail is true.

Parameters:
liste  a list object

MlCargo ml_pfx_GetPayload ML_LIST_NAME    liste
 

returns the current node's payload value.

<prefix>GetPayload returns the current node's payload value. If the current node is invalid (that is, head or tail) ML_INVALID is returned.

Parameters:
liste  a list object

ML_LIST_NAME ml_pfx_Init  
 

initialises a new instance of a list object.

<prefix>Init initialises and returns a new instance of a list object

Returns:
returns an empty list object

int ml_pfx_InsertAfter ML_LIST_NAME    liste,
MlCargo    new_load
 

inserts a new node after the current one into the list.

<prefix>InsertAfter inserts a new node into the list, directly after the node which is marked as "current" at this moment. It's payload value is set to "new_load", which must be of the appropriate data type for this list. The new node is selected as the new "current node".

Parameters:
liste  a list object
new_load  data to store in the new node
Returns:
returns 0 on success and -1 or the current node is the tail

int ml_pfx_InsertBefore ML_LIST_NAME    liste,
MlCargo    new_load
 

inserts a new node in front of the current one into the list.

<prefix>InsertBefore inserts a new node into the list, directly in fort of the node which is marked as "current" at this moment. It's payload value is set to "new_load", which must be of the appropriate data type for this list. The new node is selected as the new "current node".

Parameters:
liste  a list object
new_load  data to store in the new node
Returns:
returns 0 on success and -1 or the current node is the head

int ml_pfx_IsEmpty ML_LIST_NAME    liste
 

returns true if the list is empty.

Parameters:
liste  a list object

int ml_pfx_IsHead ML_LIST_NAME    liste
 

returns true if the current node is the list's head.

Parameters:
liste  a list object

int ml_pfx_IsTail ML_LIST_NAME    liste
 

returns true if the current node is the list's tail.

Parameters:
liste  a list object

int ml_pfx_IsValid ML_LIST_NAME    liste
 

returns true if the current node is invalid (that is, head or tail).

Parameters:
liste  a list object

int ml_pfx_IsValidValue MlCargo    load
 

returns true if the given MlCargo does not equal ML_INVALID.

Parameters:
load  the MlCargo object to query

void ml_pfx_Last ML_LIST_NAME    liste
 

selects the last node as the "current" one.

<prefix>Last selects the list's last node as the "current" node. If the list is empty, the list's head is selected, that is, the current node gets invalid and <prefix>IsHead is true.

Parameters:
liste  a list object

void ml_pfx_Next ML_LIST_NAME    liste
 

selects the node after the currently selected node.

<prefix>Next makes the node after the currently selected node the "current node". If the currently selected node is the list's tail, this function has no effect.

Parameters:
liste  a list object

void ml_pfx_Prepend ML_LIST_NAME    liste,
MlCargo    new_load
 

prepends a new node to the beginning of the list.

<prefix>Prepend creates a new node and prepends it to the beginning of the list. It's payload value is set to "new_load", which must be of the appropriate data type for this list. The new node is selected as the new "current node".

Parameters:
liste  a list object
new_load  data to store in the new node

void ml_pfx_Prev ML_LIST_NAME    liste
 

selects the node in front of the currently selected node.

<prefix>Prev makes the node in front of the currently selected node the "current node". If the currently selected node is the list's head, this function has no effect.

Parameters:
liste  a list object

int ml_pfx_SetPayload ML_LIST_NAME    liste,
MlCargo    new_load
 

sets the current node's payload value.

<prefix>SetPayload sets the current node's payload value and returns the current payload. If the current node is invalid (that is, head or tail) ML_INVALID is returned.

Parameters:
liste  a list object
new_load  a new payload value of an appropriate data type

int ml_pfx_Terminate ML_LIST_NAME    liste
 

frees all ressources allocated by the list (complementary function to list_prfx_Init()).

WARNING: Is you are using a list of pointer to some objects, these are NOT freed by the current implementation of mlist_tmpl!!! You have to free these pointer manually!

Parameters:
liste  a list object
Return values:
0  all ressources are freed, the list has been successfully destructed
-1  ERROR, the list is not empty. Nothing has been changed.
Bug:
always executes the deletion loop, even if no meaningful ML_FREE_CARGO has been defined


Generated on Fri Jan 25 22:40:55 2002 for PDepp Webserver by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001