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.
-
Matrix()
- Constructs an empty matrix.
-
addElement(int, int, Object)
- Adds the given element to this matrix at the specified row and column.
-
elementAt(int, int)
- Returns the element at the specified row and column.
-
elements()
- Returns an enumeration of all the elements.
-
insertRow(int)
- Inserts a new row at the given location.
-
printRow(int)
- Prints the specified row to System.out.
-
removeAllElements()
- Removes all elements of the matrix.
-
removeElementAt(int, int)
- Deletes the element at the specified row and column.
-
removeRow(int)
- Deletes all elements on the specified row.
-
rows()
- Returns the number of rows in the matrix.
-
sort(CompareFunc, int)
- Sorts all rows into ascending order.
-
toString()
- Returns a string representation of this component.
-
updateElement(int, int, Object)
- Adds or updates the element at the specified row and column, as needed.
Matrix
public Matrix()
- Constructs an empty matrix.
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
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
removeAllElements
public synchronized void removeAllElements()
- Removes all elements of the matrix. The matrix becomes empty.
- See Also:
- addElement, removeElementAt
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
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
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
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
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
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
rows
public synchronized int rows()
- Returns the number of rows in the matrix.
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.
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