BitArray.bitsSet

Return a lazy range of the indices of set bits.

struct BitArray
@property const nothrow
bitsSet
()

Examples

import std.algorithm.comparison : equal;

auto b1 = BitArray([0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]);
assert(b1.bitsSet.equal([4, 5, 6, 7, 12, 13, 14, 15]));

BitArray b2;
b2.length = 1000;
b2[333] = true;
b2[666] = true;
b2[999] = true;
assert(b2.bitsSet.equal([333, 666, 999]));

Meta