]> begriffs open source - libderp/blob - include/list.h
Clean includes
[libderp] / include / list.h
1 #ifndef LIBDERP_LIST_H
2 #define LIBDERP_LIST_H
3
4 #include "common.h"
5
6 #include <stdbool.h>
7 #include <stddef.h>
8
9 /* client should look inside */
10 typedef struct list_item
11 {
12         void *data;
13         struct list_item *prev, *next;
14 } list_item;
15
16 /* but this should be opaque */
17 typedef struct list list;
18
19 list *      l_new(void);
20 void        l_free(list *);
21 void        l_dtor(list *, dtor *, void *);
22 size_t      l_length(const list *);
23 bool        l_is_empty(const list *);
24 list_item * l_first(const list *);
25 list_item * l_last(const list *);
26 list_item * l_find(const list *, const void *,
27                    comparator *, void *aux);
28 list_item * l_find_last(const list *, const void *,
29                         comparator *, void * aux);
30 bool        l_append(list *, void *);
31 bool        l_prepend(list *, void *);
32 void *      l_remove_first(list *);
33 void *      l_remove_last(list *);
34 bool        l_remove(list *, list_item *);
35 bool        l_insert(list *, list_item *, void *);
36 bool        l_insert_after(list *, list_item *, void *);
37 bool        l_clear(list *);
38 bool        l_sort(list *, comparator *, void *aux);
39
40 #endif