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)
-
addElement(double)
- Adds the specified double as the last element of the OrderedCollection.
-
addElement(int)
- Adds the specified int as the last element of the OrderedCollection.
-
addElement(Object)
- Adds the specified object as the last element of the OrderedCollection.
-
addElements(Object[])
- Adds the elements of an array to the end of the collection.
-
addElements(Vector)
- Adds the elements of a Vector to the end of the collection.
-
capacity()
- Returns the current capacity of the OrderedCollection.
-
contains(Object)
- Returns true if the specified object is a value of the
collection.
-
doubleAt(int)
- Returns the double at the specified index.
-
elementAt(int)
- Returns the element at the specified index.
-
elements()
- Returns an enumeration of the elements.
-
elementsReversed()
- Returns an enumeration of the elements inrevese order.
-
ensureCapacity(int)
- Ensures that the OrderedCollection has at least the specified capacity.
-
firstElement()
- Returns the first element of the sequence.
-
indexOf(Object)
- Searches for the specified object, starting from the first position
and returns an index to it.
-
indexOf(Object, int)
- Searches for the specified object, starting at the specified
position and returns an index to it.
-
insertElementAt(Object, int)
- Inserts the specified object as an element at the specified index.
-
intAt(int)
- Returns the int at the specified index.
-
isEmpty()
- Returns true if the collection contains no values.
-
lastElement()
- Returns the last element of the sequence.
-
lastIndexOf(Object)
- Searches backwards for the specified object, starting from the last
position and returns an index to it.
-
lastIndexOf(Object, int)
- Searches backwards for the specified object, starting from the specified
position and returns an index to it.
-
removeAllElements()
- Removes all elements of the OrderedCollection.
-
removeElement(Object)
- Removes the element from the OrderedCollection.
-
removeElementAt(int)
- Deletes the element at the specified index.
-
reversed()
- Returns a OrderedCollection with elements in the reverse order
from present OrderedCollection
-
setElementAt(Object, int)
- Sets the element at the specified index to be the specified object.
-
setSize(int)
- Sets the size of the OrderedCollection.
-
shuffled()
- Returns a OrderedCollection with elements from present OrderedCollection,
but in random order.
-
size()
- Returns the number of elements in the OrderedCollection.
-
toArray()
- Converts the OrderedCollection to an array.
-
toVector()
- Converts the OrderedCollection to a vector.
-
trimToSize()
- Trims the OrderedCollection's capacity down to size.
toVector
public abstract Vector toVector()
- Converts the OrderedCollection to a vector.
toArray
public abstract Object[] toArray()
- Converts the OrderedCollection to an array.
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.
ensureCapacity
public abstract void ensureCapacity(int minCapacity)
- Ensures that the OrderedCollection has at least the specified capacity.
- Parameters:
- minCapacity - the desired minimum capacity
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
capacity
public abstract int capacity()
- Returns the current capacity of the OrderedCollection.
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.
isEmpty
public abstract boolean isEmpty()
- Returns true if the collection contains no values.
elements
public abstract Enumeration elements()
- Returns an enumeration of the elements. Use the Enumeration methods on
the returned object to fetch the elements sequentially.
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.
contains
public abstract boolean contains(Object elem)
- Returns true if the specified object is a value of the
collection.
- Parameters:
- elem - the desired element
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.
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.
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.
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.
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.
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.
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.
firstElement
public abstract Object firstElement()
- Returns the first element of the sequence.
- Throws: NoSuchElementException
- If the sequence is empty.
lastElement
public abstract Object lastElement()
- Returns the last element of the sequence.
- Throws: NoSuchElementException
- If the sequence is empty.
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.
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.
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.
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
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
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
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
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
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.
removeAllElements
public abstract void removeAllElements()
- Removes all elements of the OrderedCollection. The OrderedCollection becomes empty.
reversed
public abstract OrderedCollection reversed()
- Returns a OrderedCollection with elements in the reverse order
from present OrderedCollection
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