diff options
Diffstat (limited to 'src/libdatastruct/genset_iter.c')
-rw-r--r-- | src/libdatastruct/genset_iter.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libdatastruct/genset_iter.c b/src/libdatastruct/genset_iter.c index fba95de..f78945d 100644 --- a/src/libdatastruct/genset_iter.c +++ b/src/libdatastruct/genset_iter.c @@ -4,16 +4,16 @@ #include <skalibs/functypes.h> #include <skalibs/genset.h> -unsigned int genset_iter (genset *g, iterfunc_t_ref f, void *stuff) +unsigned int genset_iter_nocancel (genset *g, unsigned int n, iterfunc_t_ref f, void *stuff) { - unsigned char bits[bitarray_div8(g->max)] ; - unsigned int i = 0, j = 0, n = 0, m = genset_n(g) ; - bitarray_setn(bits, 0, g->max) ; - for (; i < g->sp ; i++) bitarray_clear(bits, g->freelist[i]) ; - for (i = 0 ; (i < g->max) && (j < m) ; i++) if (bitarray_peek(bits, i)) + unsigned char bits[bitarray_div8(n)] ; + unsigned int i = 0, j = 0, m = genset_n(g) ; + bitarray_setn(bits, 0, n) ; + for (; i < g->sp ; i++) if (g->freelist[i] < n) bitarray_clear(bits, g->freelist[i]) ; + for (i = 0 ; (i < n) && (j < m) ; i++) if (bitarray_peek(bits, i)) { j++ ; - if ((*f)(g->storage + i * g->esize, stuff)) n++ ; + if (!(*f)(g->storage + i * g->esize, stuff)) break ; } - return n ; + return i ; } |