Import libtu instead of using submodules
[notion/jeffpc.git] / libtu / iterable.c
blob63b00c181d02d85a0ba78d1f8aa041f87971fa95
1 /*
2 * libtu/iterable.c
4 * Copyright (c) Tuomo Valkonen 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.
8 */
10 #include "iterable.h"
13 void *iterable_nth(uint n, VoidIterator *iter, void *st)
15 void *p;
17 while(1){
18 p=iter(st);
19 if(p==NULL || n==0)
20 break;
21 n--;
24 return p;
28 bool iterable_is_on(void *p, VoidIterator *iter, void *st)
30 while(1){
31 void *p2=iter(st);
32 if(p2==NULL)
33 return FALSE;
34 if(p==p2)
35 return TRUE;
40 void *iterable_find(BoolFilter *f, void *fparam,
41 VoidIterator *iter, void *st)
43 while(1){
44 void *p=iter(st);
45 if(p==NULL)
46 return NULL;
47 if(f(p, fparam))
48 return p;