@Test public void testCanSet() { byte[][] data = QuadraticArrays.parse( "100000000", "020100000", "000320100", "010000456", "000010000", "000000010", "001000000", "000001000", "000000001" ); GameMatrixImpl matrix = new GameMatrixImpl(); matrix.setAll(data); assertTrue(matrix.canSet(0, 0, (byte) 0)); assertFalse(matrix.canSet(0, 0, (byte) 2)); assertTrue(matrix.canSet(0, 0, (byte) 3)); assertTrue(matrix.canSet(4, 8, (byte) 0)); assertTrue(matrix.canSet(4, 8, (byte) 2)); assertTrue(matrix.canSet(4, 8, (byte) 3)); }
@Override public final boolean canSet( final int row, final int column, final byte value) { assert validCoords(row, column); assert validValue(value); if (value == UNSET) { return true; } int free = getFreeMask(row, column); return (free & (1 << value)) != 0; }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { @Override public final boolean canSet( final int row, final int column, final byte value) { assert validCoords(row, column); assert validValue(value); if (value == UNSET) { return true; } int free = getFreeMask(row, column); return (free & (1 << value)) != 0; } }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { @Override public final boolean canSet( final int row, final int column, final byte value) { assert validCoords(row, column); assert validValue(value); if (value == UNSET) { return true; } int free = getFreeMask(row, column); return (free & (1 << value)) != 0; } GameMatrixImpl(); }
GameMatrixImpl implements Cloneable, BitFreeMatrixInterface { @Override public final boolean canSet( final int row, final int column, final byte value) { assert validCoords(row, column); assert validValue(value); if (value == UNSET) { return true; } int free = getFreeMask(row, column); return (free & (1 << value)) != 0; } 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 { @Override public final boolean canSet( final int row, final int column, final byte value) { assert validCoords(row, column); assert validValue(value); if (value == UNSET) { return true; } int free = getFreeMask(row, column); return (free & (1 << value)) != 0; } 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);  }