|
cu
|
#include <stdbool.h>#include <stdlib.h>Go to the source code of this file.
Data Structures | |
| struct | listnode_t |
| struct | list_t |
| Holds the reference to the head and tail of the list. More... | |
Macros | |
| #define | LIST_FOR(IT, L) |
| Iterate over the content of the list_t. More... | |
| #define | LIST_INIT |
| #define | LIST_DEL(L, FN) |
| Clear and delete a list_t, which was created on the stack. More... | |
Functions | |
| list_t * | list_new () |
| Create a new list. More... | |
| void * | list_clone (const list_t *li, void *(*clone)(void *)) |
| Clone given list. More... | |
| void | list_clear (const list_t *li, void(*df)(void *)) |
| Remove all elements from the list. More... | |
| void | list_del (list_t *li) |
| Free the memory allocated. More... | |
| void | list_clear_del (list_t *li, void(*df)(void *)) |
| Remove all elements from the list and free it. More... | |
| void | list_push_back (list_t *li, void *data) |
| Append an element to the list. More... | |
| void | list_push_front (list_t *li, void *data) |
| Prepend an element to the list. More... | |
| void | list_insert (list_t *li, const size_t index, void *data) |
| void | list_append (list_t *li, list_t *other) |
| Append another list_t to the current one. More... | |
| bool | list_is_empty (const list_t *li) |
| Check whether the list is empty. More... | |
| size_t | list_len (const list_t *li) |
| Retrieve the length of a list. More... | |
| void | list_foreach (const list_t *li, void(*f)(void *)) |
| Apply a function to every element of the list. More... | |
| void * | list_filter (const list_t *li, const void *key, bool(*pred)(const void *, const void *)) |
| Filter elements by given predicate. More... | |
| void * | list_find (const list_t *li, const void *key, bool(*pred)(const void *, const void *)) |
| Find a element in the list. More... | |
| bool | list_contains (list_t *li, const void *key, int(*pred)(const void *, const void *)) |
Interface of a dopply linked list
| #define LIST_DEL | ( | L, | |
| FN | |||
| ) |
| #define LIST_FOR | ( | IT, | |
| L | |||
| ) |
| #define LIST_INIT |
create a list_t on the stack
Append another list_t to the current one.
| li | list to append to |
| other | other list |
| void list_clear | ( | const list_t * | li, |
| void(*)(void *) | df | ||
| ) |
Remove all elements from the list.
| li | list to clear |
| df | deleting function, in case of NULL the argument is ignored |
| void list_clear_del | ( | list_t * | li, |
| void(*)(void *) | df | ||
| ) |
Remove all elements from the list and free it.
| li | List to clear and delete |
| df | Deleting function, in case of NULL the argument is ignored |
| void* list_clone | ( | const list_t * | li, |
| void *(*)(void *) | clone | ||
| ) |
Clone given list.
| li | list to clone |
| clone | function for given element. In case of NULL it is ignored |
| bool list_contains | ( | list_t * | li, |
| const void * | key, | ||
| int(*)(const void *, const void *) | pred | ||
| ) |
Check whether the list contains given key
| li | list to search |
| key | key to check |
| pred | predicate function |
| void list_del | ( | list_t * | li | ) |
Free the memory allocated.
| li | list to delete |
| void* list_filter | ( | const list_t * | li, |
| const void * | key, | ||
| bool(*)(const void *, const void *) | pred | ||
| ) |
Filter elements by given predicate.
| li | list to filter |
| key | key to find |
| pred | predicate function |
| void* list_find | ( | const list_t * | li, |
| const void * | key, | ||
| bool(*)(const void *, const void *) | pred | ||
| ) |
Find a element in the list.
| li | list to search |
| key | key to find |
| pred | predicate function |
| void list_foreach | ( | const list_t * | li, |
| void(*)(void *) | f | ||
| ) |
Apply a function to every element of the list.
| li | list |
| f | function to apply |
| void list_insert | ( | list_t * | li, |
| const size_t | index, | ||
| void * | data | ||
| ) |
Insert data into the list at given position
| li | list to insert data to |
| index | target index |
| data | data to insert |
| bool list_is_empty | ( | const list_t * | li | ) |
Check whether the list is empty.
| li | list to check |
| size_t list_len | ( | const list_t * | li | ) |
Retrieve the length of a list.
| li | list to check |
| void list_push_back | ( | list_t * | li, |
| void * | data | ||
| ) |
Append an element to the list.
| li | list to append to |
| data | data to append |
| void list_push_front | ( | list_t * | li, |
| void * | data | ||
| ) |
Prepend an element to the list.
| li | list to prepend to |
| data | data to prepend |