set method

void set(
  1. int index, [
  2. bool value = true
])

Sets the bit at index to true (or the provided value).

Implementation

void set(int index, [bool value = true]) {
  _checkBounds(index);
  final wordIndex = index ~/ 32;
  final bitIndex = index % 32;
  if (value) {
    _words[wordIndex] |= (1 << bitIndex);
  } else {
    _words[wordIndex] &= ~(1 << bitIndex);
  }
}