Cyber Garage Portable Runtime (CGPR) for C
list.c File Reference
#include <cgpr/util/list.h>

Functions

bool cg_list_header_init (CGList *list)
 
bool cg_list_node_init (CGList *list)
 
size_t cg_list_size (CGList *headList)
 
CGListcg_list_get (CGList *headList, int index)
 
bool cg_list_insert (CGList *prevList, CGList *list)
 
bool cg_list_add (CGList *headList, CGList *list)
 
bool cg_list_remove (CGList *list)
 
CGListcg_list_prev_circular (CGList *list)
 
CGListcg_list_prev (CGList *list)
 
CGListcg_list_next_circular (CGList *list)
 
CGListcg_list_gets (CGList *headList)
 
CGListcg_list_next (CGList *list)
 
bool cg_list_clear (CGList *headList, CG_LIST_DESTRUCTORFUNC dstructorFunc)
 

Function Documentation

◆ cg_list_add()

bool cg_list_add ( CGList * headList,
CGList * list )
Todo

This works essentially like insert, although it is more error-prone?!

There might be a bug in this function.

◆ cg_list_clear()

bool cg_list_clear ( CGList * headList,
CG_LIST_DESTRUCTORFUNC destructorFunc )

Clear the list and delete all of its contents with CG_LIST_DESTRUCTORFUNC

Parameters
headListList header
destructorFuncFunction pointer that clears the contents of individual nodes

◆ cg_list_get()

CGList * cg_list_get ( CGList * headList,
int index )

Get an item from the list by the item's index

Parameters
headListList header
indexThe index of the item to get

◆ cg_list_gets()

CGList * cg_list_gets ( CGList * headList)

Get the first actual item from a list for iteration

Parameters
headListList header

◆ cg_list_header_init()

bool cg_list_header_init ( CGList * list)

Initialize a list node to act as the first node

Parameters
listList node

◆ cg_list_insert()

bool cg_list_insert ( CGList * prevList,
CGList * list )

Insert a list node or a complete list structure after the given node

Parameters
prevListInsert after this node
listList node or list structure to insert

◆ cg_list_next()

CGList * cg_list_next ( CGList * list)

Get the next node. Returns NULL if end has been reached.

Parameters
listCurrent node

◆ cg_list_next_circular()

CGList * cg_list_next_circular ( CGList * list)

Get the next node. Wrap around if the end has been reached.

Parameters
listCurrent node

◆ cg_list_node_init()

bool cg_list_node_init ( CGList * list)

Initialize a list node to act as a regular node, part of a list.

Parameters
listList node

◆ cg_list_prev()

CGList * cg_list_prev ( CGList * list)

Get the previous node. Returns NULL if beginning has been reached

Parameters
listCurrent node

◆ cg_list_prev_circular()

CGList * cg_list_prev_circular ( CGList * list)

Get the previous node. Wrap around if the beginning has been reached.

Parameters
listCurrent node

◆ cg_list_remove()

bool cg_list_remove ( CGList * list)

Remove a node from a list. Does not free any memory, but only removes the next and previous link associations regarding the given node.

Parameters
listList node to remove

◆ cg_list_size()

size_t cg_list_size ( CGList * headList)

Get the number of nodes in the current list structure. Counts forwards from the given node, so if you want to get the complete size, give a header node as the parameter.

Parameters
headListList header