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.
-
Matrix(int, int, MatrixHelper)
- Construct a Matrix with the specified dimension and optionally
a MatrixHelper object.
-
getColCount()
- Get the number of columns.
-
getColInfo(int)
- Get the column info attribute.
-
getObject(int, int)
- Return the value in the cell.
-
getRowCount()
- Get the number of rows.
-
getRowInfo(int)
- Get the row info attribute.
-
insertCol(int, int)
- Insert Rows to the matrix.
-
insertRow(int, int)
- Insert rows to the matrix.
-
moveCol(int, int)
- Move a column from one location to another.
-
moveRow(int, int)
- Move a row from one location to another.
-
removeCol(int, int)
- Remove columns from matrix.
-
removeRow(int, int)
- Remove rows from matrix.
-
setColCount(int)
- Set the number of columns.
-
setColInfo(int, Object)
- Set the column info attribute.
-
setObject(int, int, Object)
- Set the content of a cell.
-
setRowCount(int)
- Set the number of rows.
-
setRowInfo(int, Object)
- Set the row info attribute.
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.
getRowInfo
public Object getRowInfo(int r)
- Get the row info attribute.
- Parameters:
- r - row number.
- Returns:
- row info attribute.
setRowInfo
public void setRowInfo(int r,
Object info)
- Set the row info attribute.
- Parameters:
- r - row number.
- info - row info.
getColInfo
public Object getColInfo(int c)
- Get the column info attribute.
- Parameters:
- c - column number.
- Returns:
- column info.
setColInfo
public void setColInfo(int c,
Object info)
- Set the column info attribute.
- Parameters:
- c - column number.
- info - column info.
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.
removeRow
public void removeRow(int r,
int n)
- Remove rows from matrix.
- Parameters:
- r - row number.
- n - number of rows.
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.
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.
removeCol
public void removeCol(int c,
int n)
- Remove columns from matrix.
- Parameters:
- r - row number.
- n - number of rows.
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.
getRowCount
public int getRowCount()
- Get the number of rows.
- Returns:
- number of rows.
setRowCount
public void setRowCount(int nrow)
- Set the number of rows. Expend or shrink the matrix if necessary.
- Parameters:
- nrow - number of rows.
getColCount
public int getColCount()
- Get the number of columns.
- Returns:
- number of columns.
setColCount
public void setColCount(int ncol)
- Set the number of columns. Expend or shrink the matrix if necessary.
- Parameters:
- ncol - number of columns.
getObject
public Object getObject(int r,
int c)
- Return the value in the cell.
- Parameters:
- r - row number.
- c - column number.
- Returns:
- cell content.
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