edu.hawaii.ics.yucheng
Class Matrix<T>

java.lang.Object
  extended by edu.hawaii.ics.yucheng.Matrix<T>
Type Parameters:
T - The type stored as matrix elements.
Direct Known Subclasses:
JadeSolver.SolutionMatrix

 class Matrix<T>
extends java.lang.Object

A generic matrix class.


Field Summary
private  java.util.ArrayList<T> myArray
           
private  int myColumns
           
private  int myRows
           
 
Constructor Summary
  Matrix(int rows, int columns, T defaultValue)
          Initializes a new instance of the class.
protected Matrix(Matrix<T> matrix)
          Clones a matrix.
 
Method Summary
 Matrix<T> clone()
          Returns a clone of the matrix.
 int columns()
          Returns the number of columns.
 T get(int row, int column)
          Returns the element value at a specified position.
 int rows()
          Returns the number of rows.
 void set(int row, int column, T value)
          Sets the element value at the specified position.
 java.lang.String toString()
          Returns the string representation of the class.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myArray

private final java.util.ArrayList<T> myArray

myColumns

private final int myColumns

myRows

private final int myRows
Constructor Detail

Matrix

public Matrix(int rows,
              int columns,
              T defaultValue)
Initializes a new instance of the class.

Parameters:
rows - The number of rows.
columns - The number of columns.
defaultValue - The default value.

Matrix

protected Matrix(Matrix<T> matrix)
Clones a matrix.

Parameters:
matrix - The matrix to clone.
Method Detail

clone

public Matrix<T> clone()
Returns a clone of the matrix.

Overrides:
clone in class java.lang.Object
Returns:
A clone of the matrix.

columns

public int columns()
Returns the number of columns.

Returns:
The number of columns.

get

public T get(int row,
             int column)
Returns the element value at a specified position.

Parameters:
row - The row.
column - The column.
Returns:
The element.

rows

public int rows()
Returns the number of rows.

Returns:
The number of rows.

set

public void set(int row,
                int column,
                T value)
Sets the element value at the specified position.

Parameters:
row - The row.
column - The column.
value - The value.

toString

public java.lang.String toString()
Returns the string representation of the class.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the class.