]> git.decadent.org.uk Git - ion3.git/blob - libtu/iterable.h
[svn-inject] Installing original source of ion3
[ion3.git] / libtu / iterable.h
1 /*
2  * libtu/iterable.h
3  *
4  * Copyright (c) Tuomo Valkonen 2005.
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_ITERABLE_H
11 #define LIBTU_ITERABLE_H
12
13 #include "types.h"
14 #include "obj.h"
15
16 typedef void *VoidIterator(void *);
17 typedef Obj *ObjIterator(void *);
18
19 typedef bool BoolFilter(void *p, void *param);
20
21 #define FOR_ALL_ITER(INIT, ITER, VAR, LL, TMP) \
22     for(INIT(TMP, LL), (VAR)=ITER(TMP); (VAR)!=NULL; VAR=ITER(TMP))
23
24 extern void *iterable_nth(uint n, VoidIterator *iter, void *st);
25 extern bool iterable_is_on(void *p, VoidIterator *iter, void *st);
26 extern void *iterable_find(BoolFilter *f, void *fparam, 
27                            VoidIterator *iter, void *st);
28     
29 #endif /* LIBTU_ITERABLE_H */