gdsl  1.6
Low-level doubly-linked list manipulation module

Typedefs

typedef _gdsl_node_t _gdsl_list_t
 GDSL low-level doubly-linked list type.

Functions

_gdsl_list_t _gdsl_list_alloc (const gdsl_element_t E)
 Create a new low-level list.
void _gdsl_list_free (_gdsl_list_t L, const gdsl_free_func_t FREE_F)
 Destroy a low-level list.
bool _gdsl_list_is_empty (const _gdsl_list_t L)
 Check if a low-level list is empty.
ulong _gdsl_list_get_size (const _gdsl_list_t L)
 Get the size of a low-level list.
void _gdsl_list_link (_gdsl_list_t L1, _gdsl_list_t L2)
 Link two low-level lists together.
void _gdsl_list_insert_after (_gdsl_list_t L, _gdsl_list_t PREV)
 Insert a low-level list after another one.
void _gdsl_list_insert_before (_gdsl_list_t L, _gdsl_list_t SUCC)
 Insert a low-level list before another one.
void _gdsl_list_remove (_gdsl_node_t NODE)
 Remove a node from a low-level list.
_gdsl_list_t _gdsl_list_search (_gdsl_list_t L, const gdsl_compare_func_t COMP_F, void *VALUE)
 Search for a particular node in a low-level list.
_gdsl_list_t _gdsl_list_map_forward (const _gdsl_list_t L, const _gdsl_node_map_func_t MAP_F, void *USER_DATA)
 Parse a low-level list in forward order.
_gdsl_list_t _gdsl_list_map_backward (const _gdsl_list_t L, const _gdsl_node_map_func_t MAP_F, void *USER_DATA)
 Parse a low-level list in backward order.
void _gdsl_list_write (const _gdsl_list_t L, const _gdsl_node_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)
 Write all nodes of a low-level list to a file.
void _gdsl_list_write_xml (const _gdsl_list_t L, const _gdsl_node_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)
 Write all nodes of a low-level list to a file into XML.
void _gdsl_list_dump (const _gdsl_list_t L, const _gdsl_node_write_func_t WRITE_F, FILE *OUTPUT_FILE, void *USER_DATA)
 Dump the internal structure of a low-level list to a file.

Typedef Documentation

GDSL low-level doubly-linked list type.

This type is voluntary opaque. Variables of this kind could'nt be directly used, but by the functions of this module.

Definition at line 54 of file _gdsl_list.h.


Function Documentation

Create a new low-level list.

Allocate a new low-level list data structure which have only one node. The node's content is set to E.

Note:
Complexity: O( 1 )
Precondition:
nothing.
Parameters:
EThe content of the first node of the new low-level list to create.
Returns:
the newly allocated low-level list in case of success.
NULL in case of insufficient memory.
See also:
_gdsl_list_free()
void _gdsl_list_free ( _gdsl_list_t  L,
const gdsl_free_func_t  FREE_F 
)

Destroy a low-level list.

Flush and destroy the low-level list L. If FREE_F != NULL, then the FREE_F function is used to deallocated each L's element. Otherwise, nothing is done with L's elements.

Note:
Complexity: O( |L| )
Precondition:
nothing.
Parameters:
LThe low-level list to destroy.
FREE_FThe function used to deallocated L's nodes contents.
See also:
_gdsl_list_alloc()

Check if a low-level list is empty.

Note:
Complexity: O( 1 )
Precondition:
nothing.
Parameters:
LThe low-level list to check.
Returns:
TRUE if the low-level list L is empty.
FALSE if the low-level list L is not empty.

Get the size of a low-level list.

Note:
Complexity: O( |L| )
Precondition:
nothing.
Parameters:
LThe low-level list to use.
Returns:
the number of elements of L (noted |L|).
void _gdsl_list_link ( _gdsl_list_t  L1,
_gdsl_list_t  L2 
)

Link two low-level lists together.

Link the low-level list L2 after the end of the low-level list L1. So L1 is before L2.

Note:
Complexity: O( |L1| )
Precondition:
L1 & L2 must be non-empty _gdsl_list_t.
Parameters:
L1The low-level list to link before L2.
L2The low-level list to link after L1.

Insert a low-level list after another one.

Insert the low-level list L after the low-level list PREV.

Note:
Complexity: O( |L| )
Precondition:
L & PREV must be non-empty _gdsl_list_t.
Parameters:
LThe low-level list to link after PREV.
PREVThe low-level list that will be linked before L.
See also:
_gdsl_list_insert_before()
_gdsl_list_remove()

Insert a low-level list before another one.

Insert the low-level list L before the low-level list SUCC.

Note:
Complexity: O( |L| )
Precondition:
L & SUCC must be non-empty _gdsl_list_t.
Parameters:
LThe low-level list to link before SUCC.
SUCCThe low-level list that will be linked after L.
See also:
_gdsl_list_insert_after()
_gdsl_list_remove()

Remove a node from a low-level list.

Unlink the node NODE from the low-level list in which it is inserted.

Note:
Complexity: O( 1 )
Precondition:
NODE must be a non-empty _gdsl_node_t.
Parameters:
NODEThe low-level node to unlink from the low-level list in which it's linked.
See also:
_gdsl_list_insert_after()
_gdsl_list_insert_before()
_gdsl_list_t _gdsl_list_search ( _gdsl_list_t  L,
const gdsl_compare_func_t  COMP_F,
void *  VALUE 
)

Search for a particular node in a low-level list.

Research an element e in the low-level list L, by using COMP_F function to find the first element e equal to VALUE.

Note:
Complexity: O( |L| )
Precondition:
COMP_F != NULL
Parameters:
LThe low-level list to use
COMP_FThe comparison function to use to compare L's elements with VALUE to find the element e
VALUEThe value that must be used by COMP_F to find the element e
Returns:
the sub-list starting by e if it's found.
NULL if VALUE is not found in L.
_gdsl_list_t _gdsl_list_map_forward ( const _gdsl_list_t  L,
const _gdsl_node_map_func_t  MAP_F,
void *  USER_DATA 
)

Parse a low-level list in forward order.

Parse all nodes of the low-level list L in forward order. The MAP_F function is called on each node with the USER_DATA argument. If MAP_F returns GDSL_MAP_STOP, then _gdsl_list_map_forward() stops and returns its last examinated node.

Note:
Complexity: O( |L| )
Precondition:
MAP_F != NULL.
Parameters:
LTh low-level list to map.
MAP_FThe map function.
USER_DATAUser's datas.
Returns:
the first node for which MAP_F returns GDSL_MAP_STOP.
NULL when the parsing is done.
See also:
_gdsl_list_map_backward()
_gdsl_list_t _gdsl_list_map_backward ( const _gdsl_list_t  L,
const _gdsl_node_map_func_t  MAP_F,
void *  USER_DATA 
)

Parse a low-level list in backward order.

Parse all nodes of the low-level list L in backward order. The MAP_F function is called on each node with the USER_DATA argument. If MAP_F returns GDSL_MAP_STOP, then _gdsl_list_map_backward() stops and returns its last examinated node.

Note:
Complexity: O( 2 |L| )
Precondition:
L must be a non-empty _gdsl_list_t & MAP_F != NULL.
Parameters:
LTh low-level list to map.
MAP_FThe map function.
USER_DATAUser's datas.
Returns:
the first node for which MAP_F returns GDSL_MAP_STOP.
NULL when the parsing is done.
See also:
_gdsl_list_map_forward()
void _gdsl_list_write ( const _gdsl_list_t  L,
const _gdsl_node_write_func_t  WRITE_F,
FILE *  OUTPUT_FILE,
void *  USER_DATA 
)

Write all nodes of a low-level list to a file.

Write the nodes of the low-level list L to OUTPUT_FILE, using WRITE_F function. Additionnal USER_DATA argument could be passed to WRITE_F.

Note:
Complexity: O( |L| )
Precondition:
WRITE_F != NULL & OUTPUT_FILE != NULL.
Parameters:
LThe low-level list to write.
WRITE_FThe write function.
OUTPUT_FILEThe file where to write L's nodes.
USER_DATAUser's datas passed to WRITE_F.
See also:
_gdsl_list_write_xml()
_gdsl_list_dump()
void _gdsl_list_write_xml ( const _gdsl_list_t  L,
const _gdsl_node_write_func_t  WRITE_F,
FILE *  OUTPUT_FILE,
void *  USER_DATA 
)

Write all nodes of a low-level list to a file into XML.

Write the nodes of the low-level list L to OUTPUT_FILE, into XML language. If WRITE_F != NULL, then uses WRITE_F function to write L's nodes to OUTPUT_FILE. Additionnal USER_DATA argument could be passed to WRITE_F.

Note:
Complexity: O( |L| )
Precondition:
OUTPUT_FILE != NULL.
Parameters:
LThe low-level list to write.
WRITE_FThe write function.
OUTPUT_FILEThe file where to write L's nodes.
USER_DATAUser's datas passed to WRITE_F.
See also:
_gdsl_list_write()
_gdsl_list_dump()
void _gdsl_list_dump ( const _gdsl_list_t  L,
const _gdsl_node_write_func_t  WRITE_F,
FILE *  OUTPUT_FILE,
void *  USER_DATA 
)

Dump the internal structure of a low-level list to a file.

Dump the structure of the low-level list L to OUTPUT_FILE. If WRITE_F != NULL, then uses WRITE_F function to write L's nodes to OUTPUT_FILE. Additionnal USER_DATA argument could be passed to WRITE_F.

Note:
Complexity: O( |L| )
Precondition:
OUTPUT_FILE != NULL.
Parameters:
LThe low-level list to dump.
WRITE_FThe write function.
OUTPUT_FILEThe file where to write L's nodes.
USER_DATAUser's datas passed to WRITE_F.
See also:
_gdsl_list_write()
_gdsl_list_write_xml()