and method

void and(
  1. BitSet set
)

Update the current BitArray using a logical AND operation with the corresponding elements in the specified set. Excess size of the set is ignored.

Implementation

void and(BitSet set) {
  var i = 0;
  // Special-case for efficient merging of two arrays.
  if (set is BitArray) {
    final minLength = math.min(_data.length, set._data.length);
    for (; i < minLength; i++) {
      _data[i] &= set._data[i];
    }
  } else {
    final iter = set.asUint32Iterable().iterator;
    for (; i < _data.length && iter.moveNext(); i++) {
      _data[i] &= iter.current;
    }
  }

  for (; i < _data.length; i++) {
    _data[i] = 0;
  }
}