|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectstructure.Matrix
public class Matrix
An implementation of rectangular vectors. This implementation of a Matrix is minimal. Few operations are provided, and no support for mathematical operations is considered.
| Field Summary | |
|---|---|
protected int |
height
|
protected Vector |
rows
|
protected int |
width
|
| Constructor Summary | |
|---|---|
Matrix()
Construct an empty matrix. |
|
Matrix(int h,
int w)
Constructs a matrix such that all values are null. |
|
| Method Summary | |
|---|---|
void |
addCol(int c)
Add a new column, whose index will be c. |
void |
addRow(int r)
Add a new row, whose index will be r. |
java.lang.Object |
get(int row,
int col)
Fetch an element from the matrix. |
int |
height()
Return the height of the matrix. |
Vector |
removeCol(int c)
Remove a column, whose index is c. |
Vector |
removeRow(int r)
Remove the row whose index is r. |
void |
set(int row,
int col,
java.lang.Object value)
Change the value at location (row, col) |
java.lang.String |
toString()
Construct a string representation of the matrix. |
int |
width()
Return the width of the matrix. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int height
protected int width
protected Vector rows
| Constructor Detail |
|---|
public Matrix()
public Matrix(int h,
int w)
h - Height of the matrix.w - Width of the matrix.| Method Detail |
|---|
public java.lang.Object get(int row,
int col)
row - The row of the elementcol - The column of the element
public void set(int row,
int col,
java.lang.Object value)
value - The new Object reference (possibly null).row - The row of the value to be changed.col - The column of the value to be changed.public void addRow(int r)
r - The index of the newly inserted row.public void addCol(int c)
c - The index of the newly inserted column.public Vector removeRow(int r)
r - The index of the to-be-removed row.
public Vector removeCol(int c)
c - The index of the column to be removed.
public int width()
public int height()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||