public void Set(int row, int col, byte value, byte bitNum) { if (row < 0) { row += Size.MatrixRows; col += 4 - ((Size.MatrixRows + 4) % 8); } if (col < 0) { col += Size.MatrixColumns; row += 4 - ((Size.MatrixColumns + 4) % 8); } if (Occupied(row, col)) { throw new InvalidOperationException($"Field already occupied row: {row} col: {col}"); } Occupy.SetBit(col + row * Size.MatrixColumns, true); bool val = ((value >> (7 - bitNum)) & 1) == 1; Matrix.SetBit(col + row * Size.MatrixColumns, val); }
public bool Occupied(int row, int col) => Occupy.GetBit(col + row * Size.MatrixColumns);