29 #define listnode_foreach(it, list) \
30 for (listnode_t * (it) = (list)->head; (it) != NULL; (it) = (it)->next)
int list_empty(list_t *list)
Checks if the list is empty.
Definition: list.c:60
struct list_t list_t
Represent the list.
list_t * list_create(void)
Create a list and set head, tail to NULL, and size to 0.
Definition: list.c:48
listnode_t * list_insert_back(list_t *list, void *value)
Insert a value at the back of list.
Definition: list.c:94
listnode_t * list_pop_front(list_t *list)
Remove and return the head of the list.
Definition: list.c:220
int list_get_index_of_value(list_t *list, void *value)
Checks if the given value is contained inside the list.
Definition: list.c:265
void list_merge(list_t *target, list_t *source)
Append source at the end of target.
Definition: list.c:329
listnode_t * list_find(list_t *list, void *value)
Searches the node of the list which points at the given value.
Definition: list.c:180
void * list_remove_by_index(list_t *list, unsigned int index)
Removes a node from the list at the given index.
Definition: list.c:301
void list_push_back(list_t *list, void *value)
Insert after tail of list(same as insert back).
Definition: list.c:192
unsigned int list_size(list_t *list)
Get list size.
Definition: list.c:53
void list_push_front(list_t *list, void *value)
Insert before head of list(same as insert front).
Definition: list.c:235
void * list_peek_back(list_t *list)
Get the value of the last element but not remove it.
Definition: list.c:254
listnode_t * list_get_node_by_index(list_t *list, unsigned int index)
Returns the node at the given index.
Definition: list.c:282
void * list_remove_front(list_t *list)
Remove a value at the front of list.
Definition: list.c:138
listnode_t * list_insert_front(list_t *list, void *value)
Insert a value at the front of list.
Definition: list.c:71
void * list_remove_node(list_t *list, listnode_t *node)
Given a listnode, remove it from list.
Definition: list.c:117
void * list_remove_back(list_t *list)
Remove a value at the back of list.
Definition: list.c:159
listnode_t * list_pop_back(list_t *list)
Remove and return the tail of the list.
Definition: list.c:200
struct listnode_t listnode_t
Represent the node of a list.
void * list_peek_front(list_t *list)
Get the value of the first element but not remove it.
Definition: list.c:243
void list_destroy(list_t *list)
Destroy a list.
Definition: list.c:313
Represent the list.
Definition: list.h:19
listnode_t * tail
The last element of the list.
Definition: list.h:23
unsigned int size
The size of the list.
Definition: list.h:25
listnode_t * head
The first element of the list.
Definition: list.h:21
Represent the node of a list.
Definition: list.h:9
struct listnode_t * next
The next node.
Definition: list.h:15
void * value
A pointer to the value.
Definition: list.h:11
struct listnode_t * prev
The previous node.
Definition: list.h:13