jds.collection
Class SparseMatrix

java.lang.Object
  |
  +--jds.collection.SparseMatrix

public class SparseMatrix
extends java.lang.Object
implements Matrix

SparseMatrix - sparse two dimensional indexed collection; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Collection, Serialized Form

Constructor Summary
SparseMatrix()
          initialize a newly created sparse matrix
SparseMatrix(java.lang.Object d)
          initialize a newly created sparse matrix
 
Method Summary
 java.lang.Object elementAt(int i, int j)
          find element at give location
 int numberColumns()
          determine number of columns in matrix
 int numberRows()
          determine number of rows in matrix
 void setElementAt(java.lang.Object v, int i, int j)
          change element at given location
 void setSize(int rows, int columns)
          set bounds in number of rows and columns
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseMatrix

public SparseMatrix()
initialize a newly created sparse matrix

SparseMatrix

public SparseMatrix(java.lang.Object d)
initialize a newly created sparse matrix
Parameters:
d - default value to use for uninitialized fields
Method Detail

setSize

public void setSize(int rows,
                    int columns)
set bounds in number of rows and columns
Specified by:
setSize in interface Matrix
Parameters:
rows - number of rows in matrix
columns - number of columns in matrix

numberRows

public int numberRows()
determine number of rows in matrix
Specified by:
numberRows in interface Matrix
Returns:
number of rows as integer

numberColumns

public int numberColumns()
determine number of columns in matrix
Specified by:
numberColumns in interface Matrix
Returns:
number of columns in matrix as integer

elementAt

public java.lang.Object elementAt(int i,
                                  int j)
find element at give location
Specified by:
elementAt in interface Matrix
Parameters:
i - index for row dimension of matrix
j - index for column dimension of matrix
Returns:
object stored at given location
Throws:
java.lang.ArrayIndexOutOfBoundsException - index is illegal

setElementAt

public void setElementAt(java.lang.Object v,
                         int i,
                         int j)
change element at given location
Specified by:
setElementAt in interface Matrix
Parameters:
v - new value for position
i - index for row dimension of matrix
j - index for column dimension of matrix
Throws:
java.lang.ArrayIndexOutOfBoundsException - index is illegal