All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.Matrix

java.lang.Object
   |
   +----symantec.itools.awt.Matrix

public final class Matrix
extends Object
This class implements a sparse matrix of objects.


Constructor Index

 o Matrix()
Constructs an empty matrix.

Method Index

 o addElement(int, int, Object)
Adds the given element to this matrix at the specified row and column.
 o elementAt(int, int)
Returns the element at the specified row and column.
 o elements()
Returns an enumeration of all the elements.
 o insertRow(int)
Inserts a new row at the given location.
 o printRow(int)
Prints the specified row to System.out.
 o removeAllElements()
Removes all elements of the matrix.
 o removeElementAt(int, int)
Deletes the element at the specified row and column.
 o removeRow(int)
Deletes all elements on the specified row.
 o rows()
Returns the number of rows in the matrix.
 o sort(CompareFunc, int)
Sorts all rows into ascending order.
 o toString()
Returns a string representation of this component.
 o updateElement(int, int, Object)
Adds or updates the element at the specified row and column, as needed.

Constructors

 o Matrix
  public Matrix()
Constructs an empty matrix.

Methods

 o addElement
  public synchronized void addElement(int r,
                                      int c,
                                      Object o) throws IllegalArgumentException
Adds the given element to this matrix at the specified row and column.

Parameters:
r - the row of the element to be added
c - the column of the element to added
o - the element to be added
Throws: IllegalArgumentException
if an element is already allocated at [r,c]
See Also:
updateElement, removeElementAt
 o updateElement
  public synchronized void updateElement(int r,
                                         int c,
                                         Object obj)
Adds or updates the element at the specified row and column, as needed.

Parameters:
r - the row of the element to be updated
c - the column of the element to updated
o - the new element
See Also:
addElement, removeElementAt
 o removeAllElements
  public synchronized void removeAllElements()
Removes all elements of the matrix. The matrix becomes empty.

See Also:
addElement, removeElementAt
 o elementAt
  public synchronized Object elementAt(int r,
                                       int c) throws ArrayIndexOutOfBoundsException
Returns the element at the specified row and column.

Parameters:
r - the row of the element to remove
c - the column of the element to remove
Returns:
the element at [r,c]
Throws: ArrayIndexOutOfBoundsException
if an invalid row and/or column was given
 o removeElementAt
  public synchronized void removeElementAt(int r,
                                           int c) throws ArrayIndexOutOfBoundsException
Deletes the element at the specified row and column.

Parameters:
r - the row of the element to remove
c - the column of the element to remove
Throws: ArrayIndexOutOfBoundsException
if an invalid row and/or column was given
 o removeRow
  public synchronized void removeRow(int r)
Deletes all elements on the specified row.

Parameters:
r - the row of the elements to remove
See Also:
insertRow, removeElementAt
 o insertRow
  public synchronized void insertRow(int r)
Inserts a new row at the given location. It does this by incrementing the row number of all elements with row indexes >= given row number.

Parameters:
r - the number of the row to insert
See Also:
removeRow
 o sort
  public synchronized void sort(CompareFunc f,
                                int c)
Sorts all rows into ascending order. It does this by comparing elements at the given column number using the provided CompareFunc.

Parameters:
f - compares two objects and determines which one is less than the other
c - the column number of elements to compare
 o printRow
  public synchronized void printRow(int r)
Prints the specified row to System.out. This can be handy for debugging purposes.

Parameters:
r - the row to print
 o rows
  public synchronized int rows()
Returns the number of rows in the matrix.

 o elements
  public synchronized MatrixEnumeration elements()
Returns an enumeration of all the elements. Use the enumeration methods of the returned object to fetch the elements sequentially.

 o toString
  public synchronized String toString()
Returns a string representation of this component. This is a standard Java AWT method which gets called to generate a string that represents this component.

Returns:
a meaningful string about this object
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index