blob: 515fa4af8fb507e946fa67e8233804c0ce165fa9 (
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
|
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#include "macro.h"
#define LLIST(T) TEMPL(llist, T)
#define LINK(T) TEMPL(llist_link, T)
#endif /* LINKED_LIST_H */
#ifdef TYPE
typedef struct LINK(TYPE) {
struct LINK(TYPE)* before;
struct LINK(TYPE)* after;
TYPE* value;
} LINK(TYPE);
typedef struct {
LINK(TYPE)* head;
LINK(TYPE)* tail;
LINK(TYPE)* cur;
int length;
} LLIST(TYPE);
#define FIRST(lst) (lst)->head->after
#define LAST(lst) (lst)->tail->before
INIT_F ( LLIST(TYPE) );
FREE_F ( LLIST(TYPE) );
INIT_F ( LINK(TYPE) );
INIT_F ( LINK(TYPE), TYPE* val );
FREE_F ( LINK(TYPE) );
int PUSH(LLIST(TYPE)) ( LLIST(TYPE)* lst, TYPE* val);
int DEEP_COPY(LLIST(TYPE)) ( LLIST(TYPE)* dest, LLIST(TYPE)* src );
int APPEND(LLIST(TYPE)) ( LLIST(TYPE)* dest, LLIST(TYPE)* new );
int SIZE(LLIST(TYPE)) ( LLIST(TYPE)* llist );
int EMPTY(LLIST(TYPE)) ( LLIST(TYPE)* llist );
#endif /* TYPE */
|