From: cristianrosa Date: Wed, 26 May 2010 13:18:07 +0000 (+0000) Subject: Bugfix: setset cursors were incorrectly implemented. Now they work fine. X-Git-Tag: v3_5~1011 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/63d512caa53162dfc50dd06538e36593bbf2e78e?hp=87761c2a8db8f783a12feb505d9106e2fd154e56 Bugfix: setset cursors were incorrectly implemented. Now they work fine. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7797 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/setset.c b/src/xbt/setset.c index 7313ff094f..4a45406793 100644 --- a/src/xbt/setset.c +++ b/src/xbt/setset.c @@ -346,7 +346,7 @@ void xbt_setset_cursor_first(xbt_setset_set_t set, xbt_setset_cursor_t *cursor) for(i=0; i < set->size; i++){ if(set->bitmap[i] != 0){ for(k=0; k < BITS_INT; k++){ - if(_is_bit_set(k,set->bitmap[i])){ + if(_is_bit_set(k, set->bitmap[i])){ (*cursor)->idx = i * BITS_INT + k; return; } @@ -371,17 +371,13 @@ int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data) /* Advance a cursor to the next element */ void xbt_setset_cursor_next(xbt_setset_cursor_t cursor) { - int i,k; cursor->idx++; - /* Traverse the set and point the cursor to the first element */ - for(i = cursor->idx / BITS_INT; i < cursor->set->size; i++){ - if(cursor->set->bitmap[i] != 0){ - for(k = cursor->idx % BITS_INT; k < BITS_INT; k++){ - if(_is_bit_set(k,cursor->set->bitmap[i])){ - cursor->idx = i * BITS_INT + k; - return; - } - } + while(cursor->idx < cursor->set->size * BITS_INT) + { + if(_is_bit_set(cursor->idx % BITS_INT, cursor->set->bitmap[cursor->idx / BITS_INT])){ + return; + }else{ + cursor->idx += cursor->set->bitmap[cursor->idx / BITS_INT] ? 1 : BITS_INT; } } cursor->idx = 0; @@ -403,12 +399,4 @@ void _set_bit(unsigned int bit, unsigned int *bitmap) void _unset_bit(unsigned int bit, unsigned int *bitmap) { bitmap[bit / BITS_INT] &= ~(0x1 << (bit % BITS_INT)); -} - - - - - - - - +} \ No newline at end of file