goldman.collection.tagged.ordered
Class TaggedOrderedCollectionWrapper<T,E>

java.lang.Object
  extended by goldman.collection.tagged.TaggedCollectionWrapper<T,E>
      extended by goldman.collection.tagged.ordered.TaggedOrderedCollectionWrapper<T,E>
All Implemented Interfaces:
TaggedOrderedCollection<T,E>, TaggedCollection<T,E>, TrackedTagged<T,E>, Iterable<TaggedElement<T,E>>
Direct Known Subclasses:
TaggedBinarySearchTree, TaggedBPlusTree, TaggedBTree, TaggedDigitizedOrderedCollectionWrapper, TaggedRedBlackTree, TaggedSkipList, TaggedSortedArray, TaggedSplayTree

public abstract class TaggedOrderedCollectionWrapper<T,E>
extends TaggedCollectionWrapper<T,E>
implements TaggedOrderedCollection<T,E>, TrackedTagged<T,E>

The tagged ordered collection wrapper can wrap any ordered collection implementation, where each element in the collection is a tagged element. It is required that the comparator depends only on the tag, and the tag is immutable.


Field Summary
 
Fields inherited from class goldman.collection.tagged.TaggedCollectionWrapper
pairs, target
 
Constructor Summary
TaggedOrderedCollectionWrapper(OrderedCollection<TaggedElement<T,E>> pairs)
           
 
Method Summary
 Locator<TaggedElement<T,E>> iteratorAtEnd()
          Creates and returns a new locator initialized to AFT.
 TaggedElement<T,E> max()
          Returns a tagged element for the greatest tag in the collection (according to the comparator).
 TaggedElement<T,E> min()
          Returns a tagged element for the least tag in the collection (according to the comparator).
 T predecessor(T tag)
          This method does not require that tag is in use.
 Locator<TaggedElement<T,E>> putTracked(T tag, E element)
          Creates a new tagged element with the given values and inserts this tagged element into this collection
 T successor(T tag)
          This method does not require that tag is in use.
 
Methods inherited from class goldman.collection.tagged.TaggedCollectionWrapper
accept, clear, contains, elements, ensureCapacity, get, getCapacity, getLocator, getSize, isEmpty, iterator, put, putAll, remove, tags, toString, trimToSize, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface goldman.collection.tagged.TaggedCollection
accept, clear, contains, elements, ensureCapacity, get, getCapacity, getLocator, getSize, isEmpty, iterator, put, putAll, remove, tags, toString, trimToSize, values
 
Methods inherited from interface goldman.collection.tagged.TaggedCollection
accept, clear, contains, elements, ensureCapacity, get, getCapacity, getLocator, getSize, isEmpty, iterator, put, putAll, remove, tags, toString, trimToSize, values
 

Constructor Detail

TaggedOrderedCollectionWrapper

public TaggedOrderedCollectionWrapper(OrderedCollection<TaggedElement<T,E>> pairs)
Method Detail

min

public TaggedElement<T,E> min()
Description copied from interface: TaggedOrderedCollection
Returns a tagged element for the least tag in the collection (according to the comparator). More specifically, the first tagged element in the iteration order is returned. This method throws a NoSuchElementException when the collection is empty.

Specified by:
min in interface TaggedOrderedCollection<T,E>
Returns:
a tagged element with the smallest tag in the collection.
Throws:
NoSuchElementException - the collection is empty.

max

public TaggedElement<T,E> max()
Description copied from interface: TaggedOrderedCollection
Returns a tagged element for the greatest tag in the collection (according to the comparator). More specifically, the last tagged element in the iteration order is returned. This method throws a NoSuchElementException when the collection is empty.

Specified by:
max in interface TaggedOrderedCollection<T,E>
Returns:
a tagged element with the largest tag in the collection.
Throws:
NoSuchElementException - the collection is empty.

predecessor

public T predecessor(T tag)
This method does not require that tag is in use.

Specified by:
predecessor in interface TaggedOrderedCollection<T,E>
Parameters:
tag - the tag for which to find the predecessor
Returns:
the largest tag used by some tagged element in the collection that is less than tag.
Throws:
NoSuchElementException - there is no tag used in the collection less than tag

successor

public T successor(T tag)
This method does not require that tag is in use.

Specified by:
successor in interface TaggedOrderedCollection<T,E>
Parameters:
tag - the tag for which to find the successor
Returns:
the smallest tag used by some tagged element in the collection that is greater than tag.
Throws:
NoSuchElementException - there is no tag used in the collection greater than tag

putTracked

public Locator<TaggedElement<T,E>> putTracked(T tag,
                                              E element)
Creates a new tagged element with the given values and inserts this tagged element into this collection

Specified by:
putTracked in interface TrackedTagged<T,E>
Parameters:
tag - the tag for the tagged element to add
element - the associated data
Returns:
a locator that tracks the new tagged element
Throws:
AtCapacityException - the collection is already at capacity.

iteratorAtEnd

public Locator<TaggedElement<T,E>> iteratorAtEnd()
Creates and returns a new locator initialized to AFT.

Specified by:
iteratorAtEnd in interface TaggedOrderedCollection<T,E>