xor method

void xor(
  1. BitMatrix mask
)

Exclusive-or (XOR): Flip the bit in this BitMatrix if the corresponding mask bit is set.

@param mask XOR mask

Implementation

void xor(BitMatrix mask) {
  if (_width != mask._width ||
      _height != mask._height ||
      _rowSize != mask._rowSize) {
    throw ArgumentError('input matrix dimensions do not match');
  }
  final rowArray = BitArray(_width);
  for (int y = 0; y < _height; y++) {
    final offset = y * _rowSize;
    final row = mask.getRow(y, rowArray).getBitArray();
    for (int x = 0; x < _rowSize; x++) {
      _bits[offset + x] ^= row[x];
    }
  }
}