list.h File Reference

#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_tcc_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 Documentation

#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.

Since:
1.0.0
Parameters:
list The list to traverse.
tmp The name of the temporary cc_dlist_node_t pointer to use while traversing the list.


Typedef Documentation

A node in a doubly-linked list.

This object is used in a doubly-linked list to hold one data item.

Since:
1.0.0

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.

Since:
1.0.0


Function Documentation

cc_dlist_t* cc_dlist_create ( void   ) 

Create a new doubly-linked list.

Create and initialize a empty doubly-linked list.

Since:
1.0.0
Returns:
A new 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.

Since:
1.0.0
Parameters:
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.

Since:
1.0.0
Parameters:
list The list to insert into.
node The node to insert after.
data The data to add to the list.
Returns:
0 on success, non-zero on failure.

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.

Since:
1.0.0
Parameters:
list The list to insert into.
data The data to add to the list.
Returns:
0 on success, non-zero on failure.

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.

Since:
1.0.0
Parameters:
list The list to insert into.
data The data to add to the list.
Returns:
0 on success, non-zero on failure.

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.

Since:
1.0.0
Parameters:
list The list to remove from.
node The node to remove.
Returns:
0 on success, non-zero on failure.

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.

Since:
1.0.0
Parameters:
list The list to remove from.
pos The element to remove (zero-based).
Returns:
0 on success, non-zero on failure.

SourceForge.net Logo