public class BitMatrixextends PersistentObjectFixed sized (non resizable) n*m bit matrix. A bit matrix has a number of columns and rows, which are assigned upon instance construction - The matrix's size is then columns()*rows(). Bits are accessed via (column,row) coordinates.
Individual bits can be examined, set, or cleared. Rectangular parts (boxes) can quickly be extracted, copied and replaced. Quick iteration over boxes is provided by optimized internal iterators (forEach() methods). One
BitMatrixmay be used to modify the contents of another
BitMatrixthrough logical AND, OR, XOR and other similar operations.
Legal coordinates range from [0,0] to [columns()-1,rows()-1]. Any attempt to access a bit at a coordinate column<0 || column>=columns() || row<0 || row>=rows() will throw an IndexOutOfBoundsException. Operations involving two bit matrices (like AND, OR, XOR, etc.) will throw an IllegalArgumentException if both bit matrices do not have the same number of columns and rows.
If you need extremely quick access to individual bits: Although getting and setting individual bits with methods get(...) and put(...) is quick, it is even quicker (but not safe) to use getQuick(...) and putQuick(...).
Note that this implementation is not synchronized.