indices method

Iterable<int> indices({
  1. bool expected = true,
})

Returns an iterable over the indices with the bit set to expected.

Implementation

Iterable<int> indices({bool expected = true}) sync* {
  var mask = 0, index = 0, value = 0;
  for (var i = 0; i < length; i++) {
    if (mask == 0) {
      value = buffer[index++];
      mask = 1;
    }
    if ((value & mask != 0) == expected) {
      yield i;
    }
    mask = (mask << 1) & bitMask;
  }
}