diff options
author | Preston Pan <ret2pop@gmail.com> | 2025-01-09 16:32:55 -0800 |
---|---|---|
committer | Preston Pan <ret2pop@gmail.com> | 2025-01-09 16:32:55 -0800 |
commit | ef9ab1fd141f4057d41f2d6ed8ab8d67c44894d5 (patch) | |
tree | e4005b7a641303b021eb54c2aae5676b5f92a72d /src/include/list.h | |
parent | 1fd608288ee47c2c560817f12f14b21069fed2f6 (diff) |
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 |