|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSparseMatrix
public class SparseMatrix
Nested Class Summary | |
---|---|
class |
SparseMatrix.Node
|
Constructor Summary | |
---|---|
SparseMatrix(int r,
int c)
Create a new sparse matrix of integers with r rows and c columns. |
Method Summary | |
---|---|
int |
getByColumn(int row,
int col)
Gets the value stored at the given row and column of this sparse matrix by scanning down the given column. |
int |
getByRow(int row,
int column)
Gets the value stored at the given row and column of this sparse matrix by scanning across the given row. |
int |
getNumColumns()
Get the number of columns in this sparse matrix. |
int |
getNumElementsInColumn(int column)
Gets the number of elements stored in the given column of this sparse matrix (for debugging purposes). |
int |
getNumElementsInRow(int row)
Gets the number of elements stored in the given row of this sparse matrix (for debugging purposes). |
int |
getNumRows()
Get the number of rows in this sparse matrix. |
void |
set(int value,
int row,
int column)
Set the given row and column of this sparse matrix to the given value. |
SparseMatrix |
transpose()
Returns the transpose of this sparse matrix. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SparseMatrix(int r, int c)
r
- The number of rows in the sparse matrix.c
- The number of columns in the sparse matrix.Method Detail |
---|
public int getNumRows()
public int getNumColumns()
public void set(int value, int row, int column)
value
- The value to store in the sparse matrix.row
- The row where the value is to be stored.column
- The column where the value is to be stored.
java.lang.ArrayIndexOutOfBoundsException
- if the row or column is invalid.public int getByRow(int row, int column)
row
- The row of the desired value.column
- The column of the desired value.
public int getByColumn(int row, int col)
row
- The row of the desired value.column
- The column of the desired value.
public int getNumElementsInRow(int row)
row
- The desired row to analyze.
public int getNumElementsInColumn(int column)
column
- The desired column to analyze.
public SparseMatrix transpose()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |