@Test public void testBlock() { byte[][] data = QuadraticArrays.parse( "000000000", "111111111", "222222222", "333333333", "444444444", "555555555", "666666666", "777777777", "888888888" ); GameMatrixImpl matrix = new GameMatrixImpl(); matrix.setAll(data); byte[] target = new byte[9]; matrix.block(0,0, target); List<Integer> vals = Utility.toIntList(target); assertEquals(Arrays.asList(0,0,0,1,1,1,2,2,2), vals); matrix.block(0,6, target); vals = Utility.toIntList(target); assertEquals(Arrays.asList(0,0,0,1,1,1,2,2,2), vals); matrix.block(6,6, target); vals = Utility.toIntList(target); assertEquals(Arrays.asList(6,6,6,7,7,7,8,8,8), vals); }
protected final void block(final int row, final int column, final byte[] target) { assert target.length == SIZE; assert validCoords(row, column); int k = 0; int roundRow = roundToBlock(row); int roundColumn = roundToBlock(column); for (int i = 0; i < BLOCK_SIZE; i++) { for (int j = 0; j < BLOCK_SIZE; j++) { target[k++] = data[roundRow + i][roundColumn + j]; } } }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { protected final void block(final int row, final int column, final byte[] target) { assert target.length == SIZE; assert validCoords(row, column); int k = 0; int roundRow = roundToBlock(row); int roundColumn = roundToBlock(column); for (int i = 0; i < BLOCK_SIZE; i++) { for (int j = 0; j < BLOCK_SIZE; j++) { target[k++] = data[roundRow + i][roundColumn + j]; } } } }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { protected final void block(final int row, final int column, final byte[] target) { assert target.length == SIZE; assert validCoords(row, column); int k = 0; int roundRow = roundToBlock(row); int roundColumn = roundToBlock(column); for (int i = 0; i < BLOCK_SIZE; i++) { for (int j = 0; j < BLOCK_SIZE; j++) { target[k++] = data[roundRow + i][roundColumn + j]; } } } GameMatrixImpl(); }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { protected final void block(final int row, final int column, final byte[] target) { assert target.length == SIZE; assert validCoords(row, column); int k = 0; int roundRow = roundToBlock(row); int roundColumn = roundToBlock(column); for (int i = 0; i < BLOCK_SIZE; i++) { for (int j = 0; j < BLOCK_SIZE; j++) { target[k++] = data[roundRow + i][roundColumn + j]; } } } GameMatrixImpl(); @Override final void setAll(final byte[][] initializationData); @Override final void clear(); @Override final byte get(final int row, final int column); @Override void set(final int row, final int column, final byte value); @Override int getSetCount(); @Override final byte[][] getArray(); @Override final String toString(); @Override int hashCode(); @Override final boolean equals(final Object obj); @Override Object clone(); @Override final boolean isValid(); @Override int getFreeMask(
            final int row,
            final int column); @Override final boolean canSet(
            final int row,
            final int column,
            final byte value); }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { protected final void block(final int row, final int column, final byte[] target) { assert target.length == SIZE; assert validCoords(row, column); int k = 0; int roundRow = roundToBlock(row); int roundColumn = roundToBlock(column); for (int i = 0; i < BLOCK_SIZE; i++) { for (int j = 0; j < BLOCK_SIZE; j++) { target[k++] = data[roundRow + i][roundColumn + j]; } } } GameMatrixImpl(); @Override final void setAll(final byte[][] initializationData); @Override final void clear(); @Override final byte get(final int row, final int column); @Override void set(final int row, final int column, final byte value); @Override int getSetCount(); @Override final byte[][] getArray(); @Override final String toString(); @Override int hashCode(); @Override final boolean equals(final Object obj); @Override Object clone(); @Override final boolean isValid(); @Override int getFreeMask(
            final int row,
            final int column); @Override final boolean canSet(
            final int row,
            final int column,
            final byte value);  }