aboutsummaryrefslogtreecommitdiff
path: root/src/include/list.h
blob: 055106abd978c7a6d3a463946665258f4a2c7a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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