edu.wisc.cs.util
Class BooleanMatrix

java.lang.Object
  |
  +--edu.wisc.cs.util.BooleanMatrix

public class BooleanMatrix
extends java.lang.Object

This class implements a two dimensional boolean matrix. It uses the java.util.BitSet object as it's underlying representation.


Field Summary
protected  java.util.BitSet bits
          The underlying representation of the values in this matrix.
protected  int ncols
          The number of columns in the matrix.
protected  int nrows
          The number of rows in the matrix.
 
Constructor Summary
BooleanMatrix(int sqr)
          Constrcts a square boolean matrix of the specified size.
BooleanMatrix(int rows, int cols)
          Constructs a new boolean matrix of the specified size.
 
Method Summary
 boolean get(int r, int c)
          Queries the specified value in the matrix.
 int getNCols()
          Returns the number of columns in this matrix.
 int getNRows()
          Returns the number of rows in this matrix.
 void set(int r, int c)
          Sets the specified value in the matrix to the true state.
 void set(int r, int c, boolean value)
          Sets a specified value in the matrix to the specified state.
 void unSet(int r, int c)
          Sets the specified value in the matrix to the false state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bits

protected java.util.BitSet bits
The underlying representation of the values in this matrix.

nrows

protected final int nrows
The number of rows in the matrix.

ncols

protected final int ncols
The number of columns in the matrix.
Constructor Detail

BooleanMatrix

public BooleanMatrix(int sqr)
Constrcts a square boolean matrix of the specified size.
Parameters:
sqr - the number of rows and columns in the new matrix.
Throws:
InvalidArgumentException - if sqr is less than one.

BooleanMatrix

public BooleanMatrix(int rows,
                     int cols)
Constructs a new boolean matrix of the specified size.
Parameters:
rows - the number of rows the new matrix.
cols - the number of cols the new matrix.
Throws:
java.lang.IllegalArgumentException - if rows or cols is less than one.
Method Detail

getNRows

public int getNRows()
Returns the number of rows in this matrix.
Returns:
the number of rows in this matrix.

getNCols

public int getNCols()
Returns the number of columns in this matrix.
Returns:
the number of columns in this matrix.

set

public void set(int r,
                int c,
                boolean value)
Sets a specified value in the matrix to the specified state.
Parameters:
r - the row position of the value to be set.
c - the column position of the value to be set.
value - the state to set at the specified position.

set

public void set(int r,
                int c)
Sets the specified value in the matrix to the true state.
Parameters:
r - the row position of the value to be set.
c - the column position of the value to be set.

unSet

public void unSet(int r,
                  int c)
Sets the specified value in the matrix to the false state.
Parameters:
r - the row position of the value to be unset.
c - the column position of the value to be unset.

get

public boolean get(int r,
                   int c)
Queries the specified value in the matrix.
Parameters:
r - the row position of the value to be queried.
c - the column position of the value to be queried.
Returns:
the value at the requested position.