include/libtu/dlist.h

Fri, 26 May 2000 18:34:04 +0200

author
tuomov
date
Fri, 26 May 2000 18:34:04 +0200
changeset 13
9eb09d246c9f
parent 11
3ea4e7930c5b
child 36
63cd573ffbcf
permissions
-rw-r--r--

trunk: changeset 16
Increased MAX_NEST and MAX_TOKENS to 256

11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
1 /*
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
2 * libtu/common.h
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
3 *
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2000.
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
5 * See the included file LICENSE for details.
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
6 */
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
7
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
8 #ifndef LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
9 #define LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
10
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
11 #define LINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
12 (ITEM)->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
13 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
14 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
15 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
16 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
17 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
18 (ITEM)->PREV->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
19 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
20 }
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
21
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
22
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
23 #define LINK_ITEM_FIRST(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
24 (ITEM)->NEXT=(LIST); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
25 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
26 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
27 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
28 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
29 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
30 } \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
31 (LIST)=(ITEM);
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
32
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
33
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
34 #define LINK_ITEM_LIST LINK_ITEM
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
35
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
36
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
37 #define LINK_ITEM_BEFORE(LIST, BEFORE, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
38 (ITEM)->NEXT=(BEFORE); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
39 (ITEM)->PREV=(BEFORE)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
40 (BEFORE)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
41 if((BEFORE)==(LIST)) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
42 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
43 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
44 (ITEM)->PREV->NEXT=(ITEM)
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
45
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
46
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
47 #define LINK_ITEM_AFTER(LIST, AFTER, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
48 (ITEM)->NEXT=(AFTER)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
49 (ITEM)->PREV=(AFTER); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
50 (AFTER)->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
51 if((ITEM)->NEXT==NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
52 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
53 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
54 (ITEM)->NEXT->PREV=ITEM;
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
55
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
56
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
57 #define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
58 if((ITEM)==(LIST)){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
59 (LIST)=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
60 if((LIST)!=NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
61 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
62 }else if((ITEM)->NEXT==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
63 (ITEM)->PREV->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
64 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
65 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
66 (ITEM)->PREV->NEXT=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
67 (ITEM)->NEXT->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
68 }
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
69
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
70 #endif /* LIBTU_DLIST_H */

mercurial