jds.util
Class VisualVector

java.lang.Object
  |
  +--jds.util.VisualVector

public class VisualVector
extends java.lang.Object
implements Indexed

VisualVector - indexed collection with graphical display; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Indexed, Serialized Form

Constructor Summary
VisualVector(Indexed data)
          initialize new visual vector
 
Method Summary
 void addElementAt(java.lang.Object val, int index)
          add a new element into the collection, making collection one element larger
 java.lang.Object elementAt(int indx)
          find value at specific index location
 java.util.Enumeration elements()
          Yields enumerator for collection
 java.awt.Panel getPanel()
          yield a panel that will display the contents of the vector
 boolean isEmpty()
          Determines whether the collection is empty
 void removeElementAt(int index)
          remove a value from a collection, making collection one element smaller
 void setElementAt(java.lang.Object v, int indx)
          set value at specific location
 void setSize(int size)
          set number of elements in collection
 int size()
          Determines number of elements in collection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisualVector

public VisualVector(Indexed data)
initialize new visual vector
Parameters:
data - the vector to be displayed
Method Detail

setSize

public void setSize(int size)
set number of elements in collection
Specified by:
setSize in interface Indexed
Parameters:
size - the new size of the collection

isEmpty

public boolean isEmpty()
Determines whether the collection is empty
Returns:
true if the collection is empty

size

public int size()
Determines number of elements in collection
Returns:
number of elements in collection as integer

elements

public java.util.Enumeration elements()
Yields enumerator for collection
Returns:
an Enumeration that will yield the elements of the collection
See Also:
Enumeration

elementAt

public java.lang.Object elementAt(int indx)
find value at specific index location
Specified by:
elementAt in interface Indexed
Parameters:
index - the index of the desired value
Returns:
the desired value
Throws:
java.lang.ArrayIndexOutOfBoundsException - array index is illegal

setElementAt

public void setElementAt(java.lang.Object v,
                         int indx)
set value at specific location
Specified by:
setElementAt in interface Indexed
Parameters:
v - the value to be inserted
index - the position at which value will be inserted
Throws:
java.lang.ArrayIndexOutOfBoundsException - array index is illegal

addElementAt

public void addElementAt(java.lang.Object val,
                         int index)
add a new element into the collection, making collection one element larger
Specified by:
addElementAt in interface Indexed
Parameters:
val - the value to be inserted
index - the position at which value will be inserted, other elements will be moved upwards

removeElementAt

public void removeElementAt(int index)
remove a value from a collection, making collection one element smaller
Specified by:
removeElementAt in interface Indexed
Parameters:
index - the index of the element to be removed
Throws:
java.util.NoSuchElementException - array index is illegal

getPanel

public java.awt.Panel getPanel()
yield a panel that will display the contents of the vector
Returns:
Panel for vector display