4 * Copyright (c) Tuomo Valkonen 1999-2005.
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.
10 #ifndef LIBTU_OBJLIST_H
11 #define LIBTU_OBJLIST_H
22 Watch watch
; /* Must be kept at head of structure */
28 typedef ObjList
* ObjListIterTmp
;
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)
34 #define FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, TMP) \
35 FOR_ALL_ITER(objlist_iter_init, (TYPE)objlist_iter, VAR, LL, &(TMP))
37 #define FOR_ALL_ON_OBJLIST_REV(TYPE, VAR, LL, TMP) \
38 FOR_ALL_ITER(objlist_iter_rev_init, \
39 (TYPE)objlist_iter_rev, VAR, LL, &(TMP))
41 #define FOR_ALL_ON_OBJLIST_UNSAFE(TYPE, VAR, LL) \
42 FOR_ALL_ON_OBJLIST(TYPE, VAR, LL, objlist_iter_tmp)
44 extern ObjListIterTmp objlist_iter_tmp
;
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 bool objlist_remove(ObjList
**objlist
, Obj
*obj
);
51 extern bool objlist_contains(ObjList
*objlist
, Obj
*obj
);
52 extern void objlist_clear(ObjList
**objlist
);
53 extern void objlist_iter_init(ObjListIterTmp
*state
, ObjList
*objlist
);
54 extern Obj
*objlist_iter(ObjListIterTmp
*state
);
55 extern void objlist_iter_rev_init(ObjListIterTmp
*state
, ObjList
*objlist
);
56 extern Obj
*objlist_iter_rev(ObjListIterTmp
*state
);
57 extern bool objlist_empty(ObjList
*objlist
);
58 extern Obj
*objlist_take_first(ObjList
**objlist
);
59 extern Obj
*objlist_take_last(ObjList
**objlist
);
61 #endif /* LIBTU_OBJLIST_H */