All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Matrix

java.lang.Object
   |
   +----tea.set.Matrix

public class Matrix
extends Object
Matrix is a two dimensional data structure. In addition to a two dimensional data matrix, Matrix object also maintain two separated vecters, row info and column info. Row info vector has the same size as the number of rows in the matrix, and column info vector has the same size as the number of columns in the matrix. The row info and column info vectors are tied to the matrix. When row/column are inserted, removed, or moved, the corresponding info vector is modified respectively.

There are methods availabe for manipulating the matrix: access single cell, insert/remove/move row and columns, access row and column info attributes, and get matrix size.

A MatrixHelper can be passed to the Matrix. If a MatrixHelper is set, the matrix will always be fully populated. In another word, getObject(), getRowInfo(), and getColInfo() will never return null. If a cell or info vector is not set by the user, an object of the type will be created using the MatrixHelper object.


Constructor Index

 o Matrix(int, int, MatrixHelper)
Construct a Matrix with the specified dimension and optionally a MatrixHelper object.

Method Index

 o getColCount()
Get the number of columns.
 o getColInfo(int)
Get the column info attribute.
 o getObject(int, int)
Return the value in the cell.
 o getRowCount()
Get the number of rows.
 o getRowInfo(int)
Get the row info attribute.
 o insertCol(int, int)
Insert Rows to the matrix.
 o insertRow(int, int)
Insert rows to the matrix.
 o moveCol(int, int)
Move a column from one location to another.
 o moveRow(int, int)
Move a row from one location to another.
 o removeCol(int, int)
Remove columns from matrix.
 o removeRow(int, int)
Remove rows from matrix.
 o setColCount(int)
Set the number of columns.
 o setColInfo(int, Object)
Set the column info attribute.
 o setObject(int, int, Object)
Set the content of a cell.
 o setRowCount(int)
Set the number of rows.
 o setRowInfo(int, Object)
Set the row info attribute.

Constructors

 o Matrix
 public Matrix(int nrow,
               int ncol,
               MatrixHelper helper)
Construct a Matrix with the specified dimension and optionally a MatrixHelper object.

Parameters:
nrow - number of rows.
ncol - number of columns.
helper - matrix helper, pass null to disable auto population.

Methods

 o getRowInfo
 public Object getRowInfo(int r)
Get the row info attribute.

Parameters:
r - row number.
Returns:
row info attribute.
 o setRowInfo
 public void setRowInfo(int r,
                        Object info)
Set the row info attribute.

Parameters:
r - row number.
info - row info.
 o getColInfo
 public Object getColInfo(int c)
Get the column info attribute.

Parameters:
c - column number.
Returns:
column info.
 o setColInfo
 public void setColInfo(int c,
                        Object info)
Set the column info attribute.

Parameters:
c - column number.
info - column info.
 o insertRow
 public void insertRow(int r,
                       int n)
Insert rows to the matrix.

Parameters:
r - row number.
n - number of rows.
Returns:
the row number of the first new row.
 o removeRow
 public void removeRow(int r,
                       int n)
Remove rows from matrix.

Parameters:
r - row number.
n - number of rows.
 o moveRow
 public void moveRow(int from,
                     int to)
Move a row from one location to another.

Parameters:
from - from row number.
to - to row number.
 o insertCol
 public void insertCol(int c,
                       int n)
Insert Rows to the matrix.

Parameters:
c - column number.
n - number of columns.
Returns:
the column number of the first new column.
 o removeCol
 public void removeCol(int c,
                       int n)
Remove columns from matrix.

Parameters:
r - row number.
n - number of rows.
 o moveCol
 public void moveCol(int from,
                     int to)
Move a column from one location to another.

Parameters:
from - from column number.
to - to column number.
 o getRowCount
 public int getRowCount()
Get the number of rows.

Returns:
number of rows.
 o setRowCount
 public void setRowCount(int nrow)
Set the number of rows. Expend or shrink the matrix if necessary.

Parameters:
nrow - number of rows.
 o getColCount
 public int getColCount()
Get the number of columns.

Returns:
number of columns.
 o setColCount
 public void setColCount(int ncol)
Set the number of columns. Expend or shrink the matrix if necessary.

Parameters:
ncol - number of columns.
 o getObject
 public Object getObject(int r,
                         int c)
Return the value in the cell.

Parameters:
r - row number.
c - column number.
Returns:
cell content.
 o setObject
 public void setObject(int r,
                       int c,
                       Object v)
Set the content of a cell.

Parameters:
r - row number.
c - column number.
v - cell content.

All Packages  Class Hierarchy  This Package  Previous  Next  Index