|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TaggedCollection<T,E>
A tagged collection is a variation of an algorithmically positioned collections (e.g., ordered collection, priority queue, spatial collection) that uses a tag associated with each element to determine their proper placement within the data structure. In other words, the application provides, for each element, an external tag that is to be associated with that element in the collection. Most tagged collections permit duplicate tags. However, some tagged collections enforce the restriction that tags are unique. Each tag in such a collection is called a key, because it can be presented to the collection in order to find its associated element. However, even when the tags are unique, multiple keys may map to the same element.
Method Summary | |
---|---|
void |
accept(Visitor<? super TaggedElement<T,E>> v)
Traverses each tagged element of this collection, in the iteration order, on behalf of the visitor. |
void |
clear()
Removes all tagged elements from this collection. |
boolean |
contains(T tag)
Returns true if a tagged element with an equivalent tag exists in this collection. |
Iterator<E> |
elements()
Returns an iterator over the elements that has been initialized to just before the first element in the iteration order. |
void |
ensureCapacity(int capacity)
Increases the capacity of this tagged collection, if necessary, to ensure that it can hold at least capacity tagged elements. |
E |
get(T tag)
Returns an element with the given tag. |
int |
getCapacity()
Returns the current capacity of this tagged collection. |
Locator<TaggedElement<T,E>> |
getLocator(T tag)
Returns a locator that has been initialized to a tagged element with an equivalent tag. |
int |
getSize()
Returns the number of tagged elements, size, in this collection. |
boolean |
isEmpty()
Returns true if this collection contains no elements, and otherwise returns false. |
Iterator<TaggedElement<T,E>> |
iterator()
Returns an iterator that has been initialized to FORE. |
void |
put(T tag,
E element)
This method creates a new tagged element with the given values and inserts this tagged element into this collection. |
void |
putAll(TaggedCollection<T,E> tc)
Adds all tagged elements in tc to this tagged collection. |
E |
remove(T tag)
Removes, from this tagged collection, a tagged element with the given tag. |
Iterator<T> |
tags()
Returns an iterator over the tags that has been initialized to just before the first tag in the iteration order. |
String |
toString()
Returns a string that describes each tagged element in the collection, in the iteration order. |
void |
trimToSize()
Trims the capacity of this tagged collection to be its current size. |
Collection<E> |
values()
Returns a collection of all the elements held in this tagged collection. |
Method Detail |
---|
void accept(Visitor<? super TaggedElement<T,E>> v)
void clear()
boolean contains(T tag)
Iterator<E> elements()
void ensureCapacity(int capacity)
capacity
tagged elements.
E get(T tag)
tag
be in use. It throws a
NoSuchElementException
otherwise
int getCapacity()
Locator<TaggedElement<T,E>> getLocator(T tag)
iterator
method, this method enables
navigation, but from a specified starting point. This method
throws a NoSuchElementException
if there is no tagged element with an equivalent tag
in the collection.
int getSize()
boolean isEmpty()
Iterator<TaggedElement<T,E>> iterator()
iterator
in interface Iterable<TaggedElement<T,E>>
void put(T tag, E element)
AtCapacityException
, an unchecked exception, is thrown if the
collection is already at capacity.
void putAll(TaggedCollection<T,E> tc)
tc
to this tagged collection.
E remove(T tag)
NoSuchElementException
when there is no element with an equivalent tag.
Iterator<T> tags()
String toString()
toString
in class Object
void trimToSize()
Collection<E> values()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |