parse/bitset.c
/* A slightly tricky function to iterate over the contents
 * of a bitset. It returns true immediately if 'elt' is in
 * the bitset, otherwise it seeks forward to the next value
 * held in the bitset and stores it in elt. If there are no
 * more values, it returns false to stop iteration. Note,
 * this means that you need to increment elt every time you
 * pass through.
 *
 * Typical usage of this function:
 *
 *      for (i = 0; bsiter(set, &i); i++)
 *          use(i);
 *
 * The increment of 'i' in the for loop is needed in order
 * to prevent the function from returning the same value
 * repeatedly.
 */
A slightly tricky function to iterate over the contents
of a bitset. It returns true immediately if 'elt' is in
the bitset, otherwise it seeks forward to the next value
held in the bitset and stores it in elt. If there are no
more values, it returns false to stop iteration. Note,
this means that you need to increment elt every time you
pass through.

Typical usage of this function.



The increment of 'i' in the for loop is needed in order
to prevent the function from returning the same value
repeatedly.
A slightly tricky function to iterate over the contents of a bitset . It returns true immediately if ' elt ' is in the bitset otherwise it seeks forward to the next value held in the bitset and stores it in elt . If there are no more values it returns false to stop iteration . Note this means that you need to increment elt every time you pass through . Typical usage of this function . The increment of ' i ' in the for loop is needed in order to prevent the function from returning the same value repeatedly .
int bsiter(Bitset *bs, size_t *elt)
{
    size_t i;
    for (i = *elt; i < bsmax(bs); i++) {
        while (i < bsmax(bs) && !bs->chunks[i/Sizetbits])
            i = (i + Sizetbits) & ~(Sizetbits - 1);
        if (bshas(bs, i)) {
            *elt = i;
            return 1;
        }
    }
    return 0;
}
int bsiter ( Bitset * bs , size_t * elt ) { size_t i ; for ( i = * elt ; i < bsmax ( bs ) ; i ++ ) { while ( i < bsmax ( bs ) && ! bs -> chunks [ i / Sizetbits ] ) i = ( i + Sizetbits ) & ~ ( Sizetbits - 1 ) ; if ( bshas ( bs , i ) ) { * elt = i ; return 1 ; } } return 0 ; }
A slightly tricky function to iterate over the contents
 of a bitset.
A slightly tricky function to iterate over the contents of a bitset .