Tue, 01 Mar 2005 22:57:57 +0100
Use install-sh.
60 | 1 | /* |
2 | * libtu/objlist.h | |
3 | * | |
91 | 4 | * Copyright (c) Tuomo Valkonen 1999-2005. |
60 | 5 | * |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
8 | */ | |
9 | ||
10 | #ifndef LIBTU_OBJLIST_H | |
11 | #define LIBTU_OBJLIST_H | |
12 | ||
13 | #include "types.h" | |
94
f48ffd2f2224
Added routinesn for generic iterables.
Tuomo Valkonen <tuomov@iki.fi>
parents:
93
diff
changeset
|
14 | #include "iterable.h" |
60 | 15 | #include "obj.h" |
16 | ||
17 | ||
18 | INTRSTRUCT(ObjList); | |
19 | ||
20 | ||
21 | DECLSTRUCT(ObjList){ | |
62 | 22 | Watch watch; /* Must be kept at head of structure */ |
23 | ObjList *next, *prev; | |
24 | ObjList **list; | |
60 | 25 | }; |
26 | ||
27 | ||
91 | 28 | typedef ObjList* ObjListIterTmp; |
29 | ||
30 | #define OBJLIST_FIRST(TYPE, LL) ((LL)==NULL ? NULL : (TYPE)(LL)->watch.obj) | |
31 | #define OBJLIST_LAST(TYPE, LL) ((LL)==NULL ? NULL : (TYPE)(LL)->prev->watch.obj) | |
32 | #define OBJLIST_EMPTY(LIST) objlist_empty(LIST) | |
60 | 33 | |
91 | 34 | #define FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, TMP) \ |
93
5f72042eb91c
Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents:
92
diff
changeset
|
35 | FOR_ALL_ITER(objlist_iter_init, (TYPE)objlist_iter, VAR, LL, &(TMP)) |
60 | 36 | |
93
5f72042eb91c
Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents:
92
diff
changeset
|
37 | #define FOR_ALL_ON_OBJLIST_REV(TYPE, VAR, LL, TMP) \ |
5f72042eb91c
Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents:
92
diff
changeset
|
38 | FOR_ALL_ITER(objlist_iter_rev_init, \ |
5f72042eb91c
Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents:
92
diff
changeset
|
39 | (TYPE)objlist_iter_rev, VAR, LL, &(TMP)) |
91 | 40 | |
41 | #define FOR_ALL_ON_OBJLIST_UNSAFE(TYPE, VAR, LL) \ | |
42 | FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, objlist_iter_tmp) | |
43 | ||
44 | extern ObjListIterTmp objlist_iter_tmp; | |
45 | ||
46 | extern bool objlist_insert_last(ObjList **objlist, Obj *obj); | |
47 | extern bool objlist_insert_first(ObjList **objlist, Obj *obj); | |
48 | extern bool objlist_reinsert_last(ObjList **objlist, Obj *obj); | |
49 | extern bool objlist_reinsert_first(ObjList **objlist, Obj *obj); | |
50 | extern void objlist_remove(ObjList **objlist, Obj *obj); | |
51 | extern void objlist_clear(ObjList **objlist); | |
52 | extern void objlist_iter_init(ObjListIterTmp *state, ObjList *objlist); | |
53 | extern Obj *objlist_iter(ObjListIterTmp *state); | |
54 | extern void objlist_iter_rev_init(ObjListIterTmp *state, ObjList *objlist); | |
55 | extern Obj *objlist_iter_rev(ObjListIterTmp *state); | |
56 | extern bool objlist_empty(ObjList *objlist); | |
92
55fcdff5bcea
Added routines to take first/last elements of objlist and ptrlist.
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
57 | extern Obj *objlist_take_first(ObjList **objlist); |
55fcdff5bcea
Added routines to take first/last elements of objlist and ptrlist.
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
58 | extern Obj *objlist_take_last(ObjList **objlist); |
60 | 59 | |
60 | #endif /* LIBTU_OBJLIST_H */ |