Wed, 23 Feb 2005 19:05:01 +0100
Added dlist iteration macros.
60 | 1 | /* |
2 | * libtu/objlist.h | |
3 | * | |
4 | * Copyright (c) Tuomo Valkonen 1999-2004. | |
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" | |
14 | #include "obj.h" | |
15 | ||
16 | ||
17 | INTRSTRUCT(ObjList); | |
18 | ||
19 | ||
20 | DECLSTRUCT(ObjList){ | |
62 | 21 | Watch watch; /* Must be kept at head of structure */ |
22 | ObjList *next, *prev; | |
23 | ObjList **list; | |
60 | 24 | }; |
25 | ||
26 | ||
27 | #define FOR_ALL_ON_OBJLIST(TYPE, VAR, LIST) \ | |
62 | 28 | for((VAR)=(TYPE)objlist_init_iter(LIST); \ |
29 | (VAR)!=NULL; \ | |
30 | (VAR)=(TYPE)objlist_iter()) | |
60 | 31 | |
32 | ||
33 | bool objlist_insert(ObjList **objlist, Obj *obj); | |
34 | void objlist_remove(ObjList **objlist, Obj *obj); | |
35 | void objlist_clear(ObjList **objlist); | |
36 | Obj *objlist_init_iter(ObjList *objlist); | |
37 | Obj *objlist_iter(); | |
38 | ||
39 | #endif /* LIBTU_OBJLIST_H */ |