goldman.collection.positional
Class AbstractPositionalCollection<E>
java.lang.Object
goldman.collection.AbstractCollection<E>
goldman.collection.positional.AbstractPositionalCollection<E>
- All Implemented Interfaces:
- Collection<E>, PositionalCollection<E>, Iterable<E>
- Direct Known Subclasses:
- Array, SinglyLinkedList
public abstract class AbstractPositionalCollection<E>
- extends AbstractCollection<E>
- implements PositionalCollection<E>
The AbstractPositionalCollection provides
a basis for defining concrete positional collections by defining a useful
set of methods that can be implemented for
any positional collection in terms of the public methods from the
PositionalCollection
interface. The internal
representation can be any positional collection data structure.
Methods inherited from class goldman.collection.AbstractCollection |
accept, addAll, checkRep, clear, compare, contains, ensureCapacity, equivalent, getCapacity, getComparator, getElementAtRank, getElementAtRank, getEquivalentElement, getSize, isEmpty, retainAll, toArray, toArray, traverseForVisitor, trimToSize, writeElements |
Methods inherited from interface goldman.collection.positional.PositionalCollection |
add, bucketsort, get, heapsort, heapsort, insertionsort, insertionsort, mergesort, mergesort, positionOf, quicksort, quicksort, radixsort, remove, removeFirst, removeLast, removeRange, repositionElementByRank, repositionElementByRank, set, swap, treesort, treesort |
Methods inherited from interface goldman.collection.Collection |
accept, add, addAll, checkRep, clear, contains, ensureCapacity, getCapacity, getComparator, getEquivalentElement, getLocator, getSize, isEmpty, remove, retainAll, toArray, toArray, trimToSize |
AbstractPositionalCollection
public AbstractPositionalCollection()
AbstractPositionalCollection
public AbstractPositionalCollection(Comparator<? super E> comp)
- Parameters:
comp
- the function used
to compare two elements
toString
public String toString()
- Description copied from interface:
Collection
- Returns a string that includes each element in
this collection
(as produced by the
toString
method for that element), in the iteration order.
- Specified by:
toString
in interface Collection<E>
- Overrides:
toString
in class AbstractCollection<E>
- Returns:
- a comma-separated string showing the elements in
the iteration order. Angle brackets mark the beginning and the end
of the collection.
addFirst
public void addFirst(E value)
- Inserts it at the front (position 0) of the collection
- Specified by:
addFirst
in interface PositionalCollection<E>
- Parameters:
value
- the element to insert
addLast
public void addLast(E value)
- Inserts it at the end (position
size
) of the collection
- Specified by:
addLast
in interface PositionalCollection<E>
- Parameters:
value
- the element to insert
iterator
public abstract PositionalCollectionLocator<E> iterator()
- Creates a new positional collection locator that starts at FORE.
- Specified by:
iterator
in interface Collection<E>
- Specified by:
iterator
in interface PositionalCollection<E>
- Specified by:
iterator
in interface Iterable<E>
iteratorAt
public abstract PositionalCollectionLocator<E> iteratorAt(int pos)
- Returns a positional collection locator that is at the given position.
- Parameters:
pos
- the user position of an element
- Throws:
NoSuchElementException
- the given position is not a valid position.
iteratorAtEnd
public abstract PositionalCollectionLocator<E> iteratorAtEnd()
- Creates a new positional collection locator that starts at AFT.
- Specified by:
iteratorAtEnd
in interface PositionalCollection<E>