42 #define LIST_FOR(IT, L) struct listnode_t *IT = NULL; for (IT = L->head; \ 49 #define LIST_INIT {.head = NULL, \ 59 #define LIST_DEL(L, FN) list_clear(&L, FN); struct listnode_t *IT = NULL; \ 60 for (IT = L.head; IT != NULL; IT = IT->next) { \ 167 bool (*pred)(
const void *,
180 bool (*pred)(
const void *,
191 int (*pred)(
const void *,
const void *));
Holds the reference to the head and tail of the list.
Definition: list.h:27
void * list_clone(const list_t *li, void *(*clone)(void *))
Clone given list.
void list_push_back(list_t *li, void *data)
Append an element to the list.
void * list_filter(const list_t *li, const void *key, bool(*pred)(const void *, const void *))
Filter elements by given predicate.
void list_foreach(const list_t *li, void(*f)(void *))
Apply a function to every element of the list.
struct listnode_t * prev
Definition: list.h:21
struct listnode_t * next
Definition: list.h:19
void list_push_front(list_t *li, void *data)
Prepend an element to the list.
void list_insert(list_t *li, const size_t index, void *data)
listnode_t * tail
Definition: list.h:31
bool list_contains(list_t *li, const void *key, int(*pred)(const void *, const void *))
void list_del(list_t *li)
Free the memory allocated.
void list_append(list_t *li, list_t *other)
Append another list_t to the current one.
list_t * list_new()
Create a new list.
void list_clear(const list_t *li, void(*df)(void *))
Remove all elements from the list.
listnode_t * head
Definition: list.h:29
size_t size
Definition: list.h:33
bool list_is_empty(const list_t *li)
Check whether the list is empty.
void * data
Definition: list.h:17
void list_clear_del(list_t *li, void(*df)(void *))
Remove all elements from the list and free it.
void * list_find(const list_t *li, const void *key, bool(*pred)(const void *, const void *))
Find a element in the list.
size_t list_len(const list_t *li)
Retrieve the length of a list.