diff options
Diffstat (limited to 'src/include/list.h')
-rw-r--r-- | src/include/list.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/include/list.h b/src/include/list.h new file mode 100644 index 0000000..055106a --- /dev/null +++ b/src/include/list.h @@ -0,0 +1,36 @@ +#ifndef LIST_H +#define LIST_H +#include <stdlib.h> +#include <stdbool.h> + +typedef struct NODE_STRUCT { + void *item; + struct NODE_STRUCT *next; + struct NODE_STRUCT *prev; +} node_t; + +typedef struct { + size_t size; + node_t *head; + node_t *tail; +} list_t; + +node_t *init_node(void *item); + +void node_free(void *x, void (*freefunc)(void *)); + +list_t *init_list(); + +void list_push_front(list_t *l, void *x); + +void list_push_back(list_t *l, void *x); + +void *list_pop_back(list_t *l); + +void *list_pop_front(list_t *l); + +bool list_is_empty(list_t *l); + +void list_free(void *x, void (*freefunc)(void *)); + +#endif |