getRow method

BitArray getRow(
  1. int y,
  2. BitArray? row
)

A fast method to retrieve one row of data from the matrix as a BitArray.

@param y The row to retrieve @param row An optional caller-allocated BitArray, will be allocated if null or too small @return The resulting BitArray - this reference should always be used even when passing your own row

Implementation

BitArray getRow(int y, BitArray? row) {
  if (row == null || row.size < _width) {
    row = BitArray(_width);
  } else {
    row.clear();
  }
  final offset = y * _rowSize;
  for (int x = 0; x < _rowSize; x++) {
    row.setBulk(x * 32, _bits[offset + x]);
  }
  return row;
}