jds
Interface Indexed

All Known Implementing Classes:
VisualVector, IndexedDeque, SparseVector, Vector

public abstract interface Indexed
extends Collection

Indexed - collection with elements accessible via index; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Collection

Fields inherited from class java.io.Serializable
serialVersionUID
 
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 index)
          find value at specific index location
 void removeElementAt(int index)
          remove a value from a collection, making collection one element smaller
 void setElementAt(java.lang.Object v, int index)
          set value at specific location
 void setSize(int size)
          set number of elements in collection
 
Methods inherited from interface jds.Collection
elements, isEmpty, size
 

Method Detail

setSize

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

elementAt

public java.lang.Object elementAt(int index)
find value at specific index location
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 index)
set value at specific location
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
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
Parameters:
index - the index of the element to be removed
Throws:
java.util.NoSuchElementException - array index is illegal