public final class BitMatrix2D extends Object
long
s.Constructor and Description |
---|
BitMatrix2D(long rows,
long columns)
Create a new 2D bit matrix with the specified number of rows and columns.
|
Modifier and Type | Method and Description |
---|---|
BitMatrix2D |
and(BitMatrix2D other)
Perform a logical AND of this 2D bit matrix
and the specified 2D bit matrix.
|
BitMatrix2D |
andNot(BitMatrix2D other)
Clear all the bits in this 2D bit matrix whose corresponding
bit is set in the specified 2D bit matrix.
|
BitMatrix2D |
assign(boolean value)
Assign all values in this 2D bit matrix to
value . |
long |
cardinality()
Return the cardinality of this 2D bit matrix, the
number of bits set to true.
|
void |
clear()
Clear all the values in this 2D bit matrix.
|
long |
columns()
Return the number of columns in this 2D bit matrix.
|
boolean |
equals(Object o) |
void |
flip(long row,
long column)
Set the bit value at the specified row and column to the complement
of its current bit value.
|
void |
flip(long row0,
long column0,
long row1,
long column1)
Set all of the bit values from (
row0, column0 ), inclusive,
to (row1, column1 ), exclusive, to the complement of their
current bit values. |
void |
flipQuick(long row,
long column)
Set the bit value at the specified row and column to the complement
of its current bit value without checking bounds.
|
void |
forEach(boolean value,
BinaryProcedure<Long,Long> procedure)
Apply the specified procedure to each row and column
in this 2D bit matrix with a bit equal to the specified value.
|
boolean |
get(long row,
long column)
Return the bit value at the specified row and column.
|
boolean |
getQuick(long row,
long column)
Return the bit value at the specified row and column without checking bounds.
|
int |
hashCode() |
boolean |
intersects(BitMatrix2D other)
Return true if the specified 2D bit matrix has any bits set
to true that are also set to true in this 2D bit matrix.
|
boolean |
isEmpty()
Return true if the cardinality of this 2D bit matrix is zero.
|
BitMatrix2D |
or(BitMatrix2D other)
Perform a logical OR of this 2D bit matrix
and the specified 2D bit matrix.
|
long |
rows()
Return the number of rows in this 2D bit matrix.
|
void |
set(long row,
long column,
boolean value)
Set the bit value at the specified row and column to
value . |
void |
set(long row0,
long column0,
long row1,
long column1,
boolean value)
Set all of the bit values from (
row0, column0 ), inclusive,
to (row1, column1 ), exclusive, to the specified value. |
void |
setQuick(long row,
long column,
boolean value)
Set the bit value at the specified row and column to
value without checking bounds. |
long |
size()
Return the size of this 2D bit matrix.
|
BitMatrix2D |
xor(BitMatrix2D other)
Perform a logical XOR of this 2D bit matrix
and the specified 2D bit matrix.
|
public BitMatrix2D(long rows, long columns)
rows
- number of rows, must be >= 0
columns
- number of columns, must be >= 0
IllegalArgumentException
- if either rows
or
columns
is negativepublic long size()
public long rows()
public long columns()
public long cardinality()
public boolean isEmpty()
public void clear()
public boolean get(long row, long column)
row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
IndexOutOfBoundsException
- if row
or column
is negative or if row
or column
is greater than
or equal to rows()
or columns()
, respectivelypublic boolean getQuick(long row, long column)
row
- row indexcolumn
- column indexpublic void set(long row, long column, boolean value)
value
.row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
value
- valueIndexOutOfBoundsException
- if row
or column
is negative or if row
or column
is greater than
or equal to rows()
or columns()
, respectivelypublic void setQuick(long row, long column, boolean value)
value
without checking bounds.row
- row indexcolumn
- column indexvalue
- valuepublic void set(long row0, long column0, long row1, long column1, boolean value)
row0, column0
), inclusive,
to (row1, column1
), exclusive, to the specified value.row0
- first row, must be >= 0
and < rows()
column0
- first column, must be >= 0
and < columns()
row1
- second row, must be >= 0
, <= rows()
and >= row0
column1
- second column, must be >= 0
, <= columns()
and >= column0
value
- valueIllegalArgumentException
- if either row1
or column1
are less than row0
or column0
, respectivelyIndexOutOfBoundsException
- if any of row0
, column0
,
row1
, or column1
are negative or if either row0
or column0
are greater than or equal to rows()
or
columns()
, respectively, or if either row1
or
column1
are strictly greater than rows()
or columns()
,
respectivelypublic void flip(long row, long column)
row
- row index, must be >= 0
and < rows()
column
- column index, must be >= 0
and < columns()
IndexOutOfBoundsException
- if row
or column
is negative or if row
or column
is greater than
or equal to rows()
or columns()
, respectivelypublic void flipQuick(long row, long column)
row
- row indexcolumn
- column indexpublic void flip(long row0, long column0, long row1, long column1)
row0, column0
), inclusive,
to (row1, column1
), exclusive, to the complement of their
current bit values.row0
- first row, must be >= 0
and < rows()
column0
- first column, must be >= 0
and < columns()
row1
- second row, must be >= 0
, <= rows()
and >= row0
column1
- second column, must be >= 0
, <= columns()
and >= column0
IllegalArgumentException
- if either row1
or column1
are less than row0
or column0
, respectivelyIndexOutOfBoundsException
- if any of row0
, column0
,
row1
, or column1
are negative or if either row0
or column0
are greater than or equal to rows()
or
columns()
, respectively, or if either row1
or
column1
are strictly greater than rows()
or columns()
,
respectivelypublic BitMatrix2D assign(boolean value)
value
.value
- valuepublic boolean intersects(BitMatrix2D other)
other
- other 2D bit matrix, must not be null and must
have the same dimensions as this 2D bit matrixpublic BitMatrix2D and(BitMatrix2D other)
other
- other 2D bit matrix, must not be null and must
have the same dimensions as this 2D bit matrixpublic BitMatrix2D andNot(BitMatrix2D other)
other
- other 2D bit matrix, must not be null and must
have the same dimensions as this 2D bit matrixpublic BitMatrix2D or(BitMatrix2D other)
other
- other 2D bit matrix, must not be null and must
have the same dimensions as this 2D bit matrixpublic BitMatrix2D xor(BitMatrix2D other)
other
- other 2D bit matrix, must not be null and must
have the same dimensions as this 2D bit matrixpublic void forEach(boolean value, BinaryProcedure<Long,Long> procedure)
value
- valueprocedure
- procedure, must not be nullCopyright (c) 2004-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).