#include "CrabClaw/types.h"Data Structures | |
| struct | cc_dlist |
| A doubly-linked list. More... | |
| struct | cc_dlist_node |
| A node in a doubly-linked list. More... | |
Defines | |
| #define | CC_DLIST_FOREACH(list, tmp) for(tmp = list->head; tmp != NULL; tmp = tmp->next) |
| Loop through each element in a given list. | |
Typedefs | |
| typedef struct cc_dlist_node | cc_dlist_node_t |
| A node in a doubly-linked list. | |
| typedef struct cc_dlist | cc_dlist_t |
| A doubly-linked list. | |
Functions | |
| cc_dlist_t * | cc_dlist_create (void) |
| Create a new doubly-linked list. | |
| void | cc_dlist_destroy (cc_dlist_t *list) |
| Destroy a doubly-linked list. | |
| int | cc_dlist_insert_after (cc_dlist_t *list, cc_dlist_node_t *node, void *data) |
| Insert a new item after a given node. | |
| int | cc_dlist_insert_head (cc_dlist_t *list, void *data) |
| Insert a new item at the head of the list. | |
| int | cc_dlist_insert_tail (cc_dlist_t *list, void *data) |
| Insert a new item at the tail of the list. | |
| int | cc_dlist_remove (cc_dlist_t *list, cc_dlist_node_t *node) |
| Remove a given node from a list. | |
| int | cc_dlist_remove_at (cc_dlist_t *list, uint32 pos) |
| Remove the element at a given position in a list. | |
| #define CC_DLIST_FOREACH | ( | list, | |||
| tmp | ) | for(tmp = list->head; tmp != NULL; tmp = tmp->next) |
Loop through each element in a given list.
This macro defines a "foreach" style loop for the given list.
| list | The list to traverse. | |
| tmp | The name of the temporary cc_dlist_node_t pointer to use while traversing the list. |
| typedef struct cc_dlist_node cc_dlist_node_t |
A node in a doubly-linked list.
This object is used in a doubly-linked list to hold one data item.
| typedef struct cc_dlist cc_dlist_t |
A doubly-linked list.
This object is used to hold a doubly-linked list of free-form data items. All fields in this structure should be considered to be read-only from outside of CrabClaw.
| cc_dlist_t* cc_dlist_create | ( | void | ) |
Create a new doubly-linked list.
Create and initialize a empty doubly-linked list.
cc_dlist_t object on success, NULL on failure. | void cc_dlist_destroy | ( | cc_dlist_t * | list | ) |
Destroy a doubly-linked list.
Destroy an existing doubly-linked list. You are responsible for freeing any memory used by the data in the list. This function will free only the nodes used and the list object itself.
| list | The list to destroy. |
| int cc_dlist_insert_after | ( | cc_dlist_t * | list, | |
| cc_dlist_node_t * | node, | |||
| void * | data | |||
| ) |
Insert a new item after a given node.
This function inserts a new node with the given data after the node passed into the function.
| list | The list to insert into. | |
| node | The node to insert after. | |
| data | The data to add to the list. |
| int cc_dlist_insert_head | ( | cc_dlist_t * | list, | |
| void * | data | |||
| ) |
Insert a new item at the head of the list.
This function inserts a new node with the given data at the head of the given list.
| list | The list to insert into. | |
| data | The data to add to the list. |
| int cc_dlist_insert_tail | ( | cc_dlist_t * | list, | |
| void * | data | |||
| ) |
Insert a new item at the tail of the list.
This function inserts a new node with the given data at the tail of the given list.
| list | The list to insert into. | |
| data | The data to add to the list. |
| int cc_dlist_remove | ( | cc_dlist_t * | list, | |
| cc_dlist_node_t * | node | |||
| ) |
Remove a given node from a list.
This function removes the given node from the list. You are responsible for cleaning up any resources used by the data, this function only frees the memory used by the node itself.
| list | The list to remove from. | |
| node | The node to remove. |
| int cc_dlist_remove_at | ( | cc_dlist_t * | list, | |
| uint32 | pos | |||
| ) |
Remove the element at a given position in a list.
This function removes the element at a given position in the list passed in. You are responsible for cleaning up any resources used by the data in the node, this function only frees the memory used by the node itself.
| list | The list to remove from. | |
| pos | The element to remove (zero-based). |