-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Consider the following implementation of iteration over all set bits in a bit_set:
inline bool bitset_for_each(const bitset_t *b, bitset_iterator iterator,
void *ptr) {
size_t base = 0;
for (size_t i = 0; i < b->arraysize; ++i) {
uint64_t w = b->array[i];
while (w != 0) {
uint64_t t = w & (~w + 1);
int r = roaring_trailing_zeroes(w);
if (!iterator(r + base, ptr)) return false;
w ^= t;
}
base += 64;
}
return true;
}it uses count trailing zeroes to improve efficiency.
Blocked by #17 & dart-lang/sdk#52673, or maybe there's an efficient-enough way to simulate count trailing zeroes (e.g. https://stackoverflow.com/questions/31233609/what-is-the-most-efficient-to-count-trailing-zeroes-in-an-integer).
Metadata
Metadata
Assignees
Labels
No labels