summaryrefslogtreecommitdiffstats
path: root/include/inn/list.h
blob: 99004e43cd6e3c05ba20dbb8fdc18edd825c0693 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*  $Id: list.h 6168 2003-01-21 06:27:32Z alexk $
**
*/

#ifndef INN_LIST_H
#define INN_LIST_H 1

#include <inn/defines.h>

struct node {
    struct node *succ;
    struct node *pred;
};

struct list {
    struct node *head;
    struct node *tail;
    struct node *tailpred;
};

BEGIN_DECLS

/* initialise a new list */
void list_new(struct list *list);

/* add a node to the head of the list */
struct node *list_addhead(struct list *list, struct node *node);

/* add a node to the tail of the list */
struct node *list_addtail(struct list *list, struct node *node);

/* return a pointer to the first node on the list */
struct node *list_head(struct list *list);

/* return a pointer to the last node on the list */
struct node *list_tail(struct list *list);

struct node *list_succ(struct node *node);
struct node *list_pred(struct node *node);

struct node *list_remhead(struct list *list);
struct node *list_remove(struct node *node);
struct node *list_remtail(struct list *list);
struct node *list_insert(struct list *list, struct node *node,
			 struct node *pred);

bool list_isempty(struct list *list);

END_DECLS

#endif /* INN_LIST_H */