beowulf.model
Class IntegerMatrix

java.lang.Object
  extended bybeowulf.model.Matrix
      extended bybeowulf.model.IntegerMatrix
All Implemented Interfaces:
Collection, Serializable

public class IntegerMatrix
extends Matrix

This class is an extension to the Matrix class. This IntegerMatrix contains a two dimensional grid of java.lang.Integer objects. Some of the methods have been overridden for casting convenience, and the default value of an element of this matrix is a java.lang.Integer whose value is that of the default integer value.

Version:
1.0 11/7/2003
Author:
Andy Scukanec (ags at cs dot cornell dot edu)
See Also:
Serialized Form

Field Summary
protected  int defaultIntegerValue
           
 
Fields inherited from class beowulf.model.Matrix
data, numCols, numRows
 
Constructor Summary
IntegerMatrix()
          Creates a 1x1 IntegerMatrix with a default value of Integer.MAX_VALUE.
IntegerMatrix(int size)
          Creates a sizexsize IntegerMatrix with a default value of Integer.MAX_VALUE.
IntegerMatrix(int rows, int cols)
          Creates a rowsxcols IntegerMatrix with a default value of Integer.MAX_VALUE.
 
Method Summary
 void add(int row, int col, int value)
          This method performs just as put(int, int, Object) but does not fail when row or col are out of bounds.
 int getDefaultIntegerValue()
          This will return the integer value of the default value used by this IntegerMatrix.
 Object getDefaultValue()
          The new default value of the matrix is a java.lang.Integer whose int value depends on the instance of the matrix.
 int getInt(int row, int col)
          This method returns the object at the specified position.
 void put(int row, int col, int value)
          Sets the value at [row][col] to be a java.lang.Integer whose value is value.
 void setDefaultIntegerValue(int newValue)
          This method will set the default integer value of this matrix.
 
Methods inherited from class beowulf.model.Matrix
add, add, addAll, clear, contains, containsAll, expandBy, expandBy, expandTo, expandTo, get, getCols, getRows, isEmpty, iterator, put, remove, remove, remove, removeAll, removeCol, removeRow, retainAll, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

defaultIntegerValue

protected int defaultIntegerValue
Constructor Detail

IntegerMatrix

public IntegerMatrix()
Creates a 1x1 IntegerMatrix with a default value of Integer.MAX_VALUE.


IntegerMatrix

public IntegerMatrix(int size)
Creates a sizexsize IntegerMatrix with a default value of Integer.MAX_VALUE.

Parameters:
size - The size of the new matrix.

IntegerMatrix

public IntegerMatrix(int rows,
                     int cols)
Creates a rowsxcols IntegerMatrix with a default value of Integer.MAX_VALUE.

Parameters:
rows - The number of rows of the new matrix.
cols - The number of columns of the new matrix.
Method Detail

getDefaultIntegerValue

public int getDefaultIntegerValue()
This will return the integer value of the default value used by this IntegerMatrix. It is initially set to Integer.MAX_VALUE.

Returns:
The default integer value.

setDefaultIntegerValue

public void setDefaultIntegerValue(int newValue)
This method will set the default integer value of this matrix.

Parameters:
newValue - The new default integer value.

getDefaultValue

public Object getDefaultValue()
The new default value of the matrix is a java.lang.Integer whose int value depends on the instance of the matrix.

Overrides:
getDefaultValue in class Matrix
Returns:
A new java.lang.Integer with an int value of defaultIntegerValue.

getInt

public int getInt(int row,
                  int col)
This method returns the object at the specified position. If either row or col are out of bounds, an exception is thrown. The return value is the result of calling .intValue() on the java.lang.Integer in that position. A ClassCastException could be thrown if an object other than a java.lang.Integer was put into the matrix.

Parameters:
row - The row index of the value.
col - The column index of the value.
Returns:
The value at the indicated location.

put

public void put(int row,
                int col,
                int value)
Sets the value at [row][col] to be a java.lang.Integer whose value is value. If either row or col are out of bounds, and exception will be thrown.

Parameters:
row - The row index of the value to set.
col - The column index of the value to set.
value - The new value of the indicated position.

add

public void add(int row,
                int col,
                int value)
This method performs just as put(int, int, Object) but does not fail when row or col are out of bounds. Rather, it will expand to the size implied by row and col until the indicated location exists. The value at that point will then be set.

Parameters:
row - The row index of the value to set.
col - The column index of the value to set.
value - The new value of the indicated position.