Bit_Array module

only_set

procedure · 1 overloadSource

A loop body for visiting just the set bits, used as for: only_set bits; it is true and it_index the position.

ExampleOpen in playground ↗
bits := make_bit_array(8);
bits[1] = true;
bits[6] = true;

positions: [..] int;
for: only_set bits array_add(*positions, it_index);
assert(positions.count == 2 && positions[1] == 6);
array_free(positions);
deinit(*bits);

See also