All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface sdsu.util.OrderedCollection

public interface OrderedCollection
extends Cloneable
An OrderedCollection is a collection of objects where the objects have a location in the collection. The objects can be accessed by their location ( or index) in the collection. The first object is in location (index) 0 (zero).

Author:
Roger Whitney (whitney@cs.sdsu.edu)

Method Index

 o addElement(double)
Adds the specified double as the last element of the OrderedCollection.
 o addElement(int)
Adds the specified int as the last element of the OrderedCollection.
 o addElement(Object)
Adds the specified object as the last element of the OrderedCollection.
 o addElements(Object[])
Adds the elements of an array to the end of the collection.
 o addElements(Vector)
Adds the elements of a Vector to the end of the collection.
 o capacity()
Returns the current capacity of the OrderedCollection.
 o contains(Object)
Returns true if the specified object is a value of the collection.
 o doubleAt(int)
Returns the double at the specified index.
 o elementAt(int)
Returns the element at the specified index.
 o elements()
Returns an enumeration of the elements.
 o elementsReversed()
Returns an enumeration of the elements inrevese order.
 o ensureCapacity(int)
Ensures that the OrderedCollection has at least the specified capacity.
 o firstElement()
Returns the first element of the sequence.
 o indexOf(Object)
Searches for the specified object, starting from the first position and returns an index to it.
 o indexOf(Object, int)
Searches for the specified object, starting at the specified position and returns an index to it.
 o insertElementAt(Object, int)
Inserts the specified object as an element at the specified index.
 o intAt(int)
Returns the int at the specified index.
 o isEmpty()
Returns true if the collection contains no values.
 o lastElement()
Returns the last element of the sequence.
 o lastIndexOf(Object)
Searches backwards for the specified object, starting from the last position and returns an index to it.
 o lastIndexOf(Object, int)
Searches backwards for the specified object, starting from the specified position and returns an index to it.
 o removeAllElements()
Removes all elements of the OrderedCollection.
 o removeElement(Object)
Removes the element from the OrderedCollection.
 o removeElementAt(int)
Deletes the element at the specified index.
 o reversed()
Returns a OrderedCollection with elements in the reverse order from present OrderedCollection
 o setElementAt(Object, int)
Sets the element at the specified index to be the specified object.
 o setSize(int)
Sets the size of the OrderedCollection.
 o shuffled()
Returns a OrderedCollection with elements from present OrderedCollection, but in random order.
 o size()
Returns the number of elements in the OrderedCollection.
 o toArray()
Converts the OrderedCollection to an array.
 o toVector()
Converts the OrderedCollection to a vector.
 o trimToSize()
Trims the OrderedCollection's capacity down to size.

Methods

 o toVector
 public abstract Vector toVector()
Converts the OrderedCollection to a vector.

 o toArray
 public abstract Object[] toArray()
Converts the OrderedCollection to an array.

 o trimToSize
 public abstract void trimToSize()
Trims the OrderedCollection's capacity down to size. Use this operation to minimize the storage of a OrderedCollection. Subsequent insertions will cause reallocation.

 o ensureCapacity
 public abstract void ensureCapacity(int minCapacity)
Ensures that the OrderedCollection has at least the specified capacity.

Parameters:
minCapacity - the desired minimum capacity
 o setSize
 public abstract void setSize(int newSize)
Sets the size of the OrderedCollection. If the size shrinks, the extra elements are lost; if the size increases, the new elements are set to null.

Parameters:
newSize - the new size of the OrderedCollection
 o capacity
 public abstract int capacity()
Returns the current capacity of the OrderedCollection.

 o size
 public abstract int size()
Returns the number of elements in the OrderedCollection. Note that this is not the same as the OrderedCollection's capacity.

 o isEmpty
 public abstract boolean isEmpty()
Returns true if the collection contains no values.

 o elements
 public abstract Enumeration elements()
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

 o elementsReversed
 public abstract Enumeration elementsReversed()
Returns an enumeration of the elements inrevese order. That is starts at the back of the OrderedCollection and goes toward the front of the OrderedCollection.

 o contains
 public abstract boolean contains(Object elem)
Returns true if the specified object is a value of the collection.

Parameters:
elem - the desired element
 o indexOf
 public abstract int indexOf(Object elem)
Searches for the specified object, starting from the first position and returns an index to it.

Parameters:
elem - the desired element
Returns:
the index of the element, or -1 if it was not found.
 o indexOf
 public abstract int indexOf(Object elem,
                             int index)
Searches for the specified object, starting at the specified position and returns an index to it.

Parameters:
elem - the desired element
index - the index where to start searching
Returns:
the index of the element, or -1 if it was not found.
 o lastIndexOf
 public abstract int lastIndexOf(Object elem)
Searches backwards for the specified object, starting from the last position and returns an index to it.

Parameters:
elem - the desired element
Returns:
the index of the element, or -1 if it was not found.
 o lastIndexOf
 public abstract int lastIndexOf(Object elem,
                                 int index)
Searches backwards for the specified object, starting from the specified position and returns an index to it.

Parameters:
elem - the desired element
index - the index where to start searching
Returns:
the index of the element, or -1 if it was not found.
 o elementAt
 public abstract Object elementAt(int index)
Returns the element at the specified index.

Parameters:
index - the index of the desired element
Throws: ArrayIndexOutOfBoundsException
If an invalid index was given.
 o intAt
 public abstract int intAt(int index)
Returns the int at the specified index.

Parameters:
index - the index of the desired element
Throws: ArrayIndexOutOfBoundsException
If an invalid index was given.
Throws: ClassCastException
If element at index is not really a numeric type which can be converted to an int.
 o doubleAt
 public abstract double doubleAt(int index)
Returns the double at the specified index.

Parameters:
index - the index of the desired element
Throws: ArrayIndexOutOfBoundsException
If an invalid index was given.
Throws: ClassCastException
If element at index is not really a numeric type which can be converted to a double.
 o firstElement
 public abstract Object firstElement()
Returns the first element of the sequence.

Throws: NoSuchElementException
If the sequence is empty.
 o lastElement
 public abstract Object lastElement()
Returns the last element of the sequence.

Throws: NoSuchElementException
If the sequence is empty.
 o setElementAt
 public abstract void setElementAt(Object obj,
                                   int index)
Sets the element at the specified index to be the specified object. The previous element at that position is discarded.

Parameters:
obj - what the element is to be set to
index - the specified index
Throws: ArrayIndexOutOfBoundsException
If the index was invalid.
 o removeElementAt
 public abstract void removeElementAt(int index)
Deletes the element at the specified index. Elements with an index greater than the current index are moved down.

Parameters:
index - the element to remove
Throws: ArrayIndexOutOfBoundsException
If the index was invalid.
 o insertElementAt
 public abstract void insertElementAt(Object obj,
                                      int index)
Inserts the specified object as an element at the specified index. Elements with an index greater or equal to the current index are shifted up.

Parameters:
obj - the element to insert
index - where to insert the new element
Throws: ArrayIndexOutOfBoundsException
If the index was invalid.
 o addElement
 public abstract void addElement(Object obj)
Adds the specified object as the last element of the OrderedCollection.

Parameters:
obj - the element to be added
 o addElement
 public abstract void addElement(int anInt)
Adds the specified int as the last element of the OrderedCollection.

Parameters:
anInt - the element to be added
 o addElement
 public abstract void addElement(double aDouble)
Adds the specified double as the last element of the OrderedCollection.

Parameters:
aFloat - the element to be added
 o addElements
 public abstract void addElements(Vector elementsToAdd)
Adds the elements of a Vector to the end of the collection.

Parameters:
elementsToAdd - the elements to be added
 o addElements
 public abstract void addElements(Object elementsToAdd[])
Adds the elements of an array to the end of the collection.

Parameters:
elementsToAdd - the elements to be added
 o removeElement
 public abstract boolean removeElement(Object obj)
Removes the element from the OrderedCollection. If the object occurs more than once, only the first is removed. If the object is not an element, returns false.

Parameters:
obj - the element to be removed
Returns:
true if the element was actually removed; false otherwise.
 o removeAllElements
 public abstract void removeAllElements()
Removes all elements of the OrderedCollection. The OrderedCollection becomes empty.

 o reversed
 public abstract OrderedCollection reversed()
Returns a OrderedCollection with elements in the reverse order from present OrderedCollection

 o shuffled
 public abstract OrderedCollection shuffled()
Returns a OrderedCollection with elements from present OrderedCollection, but in random order.


All Packages  Class Hierarchy  This Package  Previous  Next  Index