#include "common.h"
#include "tmpl_common.h"
Include dependency graph for mlist_tmpl_h.inc:
This graph shows which files directly or indirectly include this file:
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... |
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.
|
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".
|
|
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...)
|
|
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".
|
|
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.
|
|
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.
|
|
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.
|
|
initialises a new instance of a list object.
<prefix>Init initialises and returns a new instance of a list object
|
|
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".
|
|
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".
|
|
returns true if the list is empty.
|
|
returns true if the current node is the list's head.
|
|
returns true if the current node is the list's tail.
|
|
returns true if the current node is invalid (that is, head or tail).
|
|
returns true if the given MlCargo does not equal ML_INVALID.
|
|
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.
|
|
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.
|
|
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".
|
|
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.
|
|
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.
|
|
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!
|