sphore 0.0.1
SPH openGL rendering engine
|
Code for generic lists. More...
Go to the source code of this file.
Typedefs | |
typedef struct _list | list_t |
public access to the list data structure. | |
typedef struct _list_iterator | list_iterator_t |
public access to the list iterator data structure. | |
Functions | |
list_t * | list_create (void) |
Creates a new list. | |
void | list_destroy (list_t *list) |
Cleans up the memory accosiated with a list object. | |
void | list_destroy_data (list_t *list, void(*destroy_func)(void *)) |
Cleans up the memory accosiated with a list object as well as the data contained at each node. | |
_SREnodeID | list_add_first (list_t *list, void *data) |
Adds a new item to the start of the given list. | |
_SREnodeID | list_add_last (list_t *list, void *data) |
Adds a new item to the end of the given list. | |
SREbool | list_remove (list_t *list, _SREnodeID id) |
Removes a node from a list. | |
SREbool | list_remove_data (list_t *list, _SREnodeID id, void(*destroy_func)(void *)) |
Removes a node from a list, as well as freeing the associated data. | |
list_iterator_t * | list_iterator_create (list_t *list) |
Creates a list_iterator_t. | |
void | list_iterator_destroy (list_iterator_t *it) |
Cleans up the memory accosiated with a list_iterator_t. | |
_SREnodeID | list_iterator_get_id (list_iterator_t *it) |
Gets the id of the node currently selected by the iterator. | |
void * | list_iterator_get_data (list_iterator_t *it) |
Gets the data of the node currently selected by the iterator. | |
void | list_iterator_remove (list_iterator_t *it) |
Removes the node currently selected by the iterator. | |
void | list_iterator_remove_data (list_iterator_t *it, void(*destroy_func)(void *)) |
Removes the node currently selected by the iterator, aswell as the data contained in te node. | |
_SREnodeID | list_iterator_add (list_iterator_t *it, void *data) |
Adds a new node at the position of the iterator. | |
SREbool | list_iterator_find (list_iterator_t *it, _SREnodeID id) |
Moves the iterator to the node containing id. | |
void | list_iterator_reset (list_iterator_t *it) |
Resets the given iterator. | |
SREbool | list_iterator_move (list_iterator_t *it) |
Moves the iterator one place through the list. | |
SREbool | list_iterator_has_next (list_iterator_t *it) |
Code for generic lists.
typedef struct _list_iterator list_iterator_t |
public access to the list iterator data structure.
Memory mamagment should be peformed with list_iterator_create and list_iterator_destroy. When ever a list is modified all associated iterators will be broken and should be reset or destoryed.
public access to the list data structure.
Memory mamagment should be peformed with list_create and list_destroy
_SREnodeID list_add_first | ( | list_t * | list, |
void * | data | ||
) |
Adds a new item to the start of the given list.
[in] | list | The list to be added to. |
[in] | data | The data for the new node. |
_SREnodeID list_add_last | ( | list_t * | list, |
void * | data | ||
) |
Adds a new item to the end of the given list.
[in] | list | The list to be added to. |
[in] | data | The data for the new node. |
list_t* list_create | ( | void | ) |
Creates a new list.
The list should be cleaned up by list_destroy.
void list_destroy | ( | list_t * | list | ) |
Cleans up the memory accosiated with a list object.
[in] | list | The list to be destroyed. |
void list_destroy_data | ( | list_t * | list, |
void(*)(void *) | destroy_func | ||
) |
Cleans up the memory accosiated with a list object as well as the data contained at each node.
[in] | list | The list to be destroyed. |
[in] | destroy_func | The function used to clean up the data. |
_SREnodeID list_iterator_add | ( | list_iterator_t * | it, |
void * | data | ||
) |
Adds a new node at the position of the iterator.
The iterator will be broken and should be reset or deleted.
[in] | it | The iterator to be used. |
[in] | data | The data for the new node. |
list_iterator_t* list_iterator_create | ( | list_t * | list | ) |
Creates a list_iterator_t.
Creates a new iterator for the given list, initialised at the start of the list. The iterator should be cleaned up by list_iterator_destroy.
[in] | list | The list for which to create an iterator. |
void list_iterator_destroy | ( | list_iterator_t * | it | ) |
Cleans up the memory accosiated with a list_iterator_t.
[in] | it | The iterator to be destroyed. |
SREbool list_iterator_find | ( | list_iterator_t * | it, |
_SREnodeID | id | ||
) |
Moves the iterator to the node containing id.
[in] | it | The iterator to be used. |
[in] | id | The id of the node to find. |
void* list_iterator_get_data | ( | list_iterator_t * | it | ) |
Gets the data of the node currently selected by the iterator.
[in] | it | The iterator to be checked. |
_SREnodeID list_iterator_get_id | ( | list_iterator_t * | it | ) |
Gets the id of the node currently selected by the iterator.
[in] | it | The iterator to be checked. |
SREbool list_iterator_has_next | ( | list_iterator_t * | it | ) |
SREbool list_iterator_move | ( | list_iterator_t * | it | ) |
Moves the iterator one place through the list.
[in] | it | The iterator to be moved. |
void list_iterator_remove | ( | list_iterator_t * | it | ) |
Removes the node currently selected by the iterator.
This routine does not remove the data in the node, for this you must use list_iterator_remove_data. The iterator will be broken and should be reset or deleted.
[in] | it | The iterator to check. |
void list_iterator_remove_data | ( | list_iterator_t * | it, |
void(*)(void *) | destroy_func | ||
) |
Removes the node currently selected by the iterator, aswell as the data contained in te node.
The iterator will be broken and should be reset or deleted.
[in] | it | The iterator to check. |
[in] | destroy_func | This function is used to clean up the data held by the node. |
void list_iterator_reset | ( | list_iterator_t * | it | ) |
Resets the given iterator.
A reset iterator has the first node selected.
[in] | it | The iterator to be reset. |
SREbool list_remove | ( | list_t * | list, |
_SREnodeID | id | ||
) |
Removes a node from a list.
This routine will not clean up the data contained in the node, for this you should use list_remove_data.
[in] | list | The list to remove the item from. |
[in] | id | The id for accosiated to the node to be removed. |
SREbool list_remove_data | ( | list_t * | list, |
_SREnodeID | id, | ||
void(*)(void *) | destroy_func | ||
) |
Removes a node from a list, as well as freeing the associated data.
This routine will call destroy_func (node->data) to clean up the data contained in the node.
[in] | list | The list to remove the item from. |
[in] | id | The id for accosiated to the node to be removed. |
[in] | destroy_func | The function used to clean up the data. |