iterable.c

Fri, 15 Mar 2013 10:12:47 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 15 Mar 2013 10:12:47 +0000
changeset 116
5f66d3bb1c68
parent 94
f48ffd2f2224
permissions
-rw-r--r--

Option help display line wrapping fix

/*
 * libtu/iterable.c
 *
 * Copyright (c) Tuomo Valkonen 2005.
 *
 * You may distribute and modify this library under the terms of either
 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
 */

#include "iterable.h"


void *iterable_nth(uint n, VoidIterator *iter, void *st)
{
    void *p;
    
    while(1){
        p=iter(st);
        if(p==NULL || n==0)
            break;
        n--;
    }
    
    return p;
}


bool iterable_is_on(void *p, VoidIterator *iter, void *st)
{
    while(1){
        void *p2=iter(st);
        if(p2==NULL)
            return FALSE;
        if(p==p2)
            return TRUE;
    }
}


void *iterable_find(BoolFilter *f, void *fparam, 
                    VoidIterator *iter, void *st)
{
    while(1){
        void *p=iter(st);
        if(p==NULL)
            return NULL;
        if(f(p, fparam))
            return p;
    }
}
        

mercurial