|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Collection<E>
The Collection
interface contains the operations that must
be supported by all data structures that maintain a collection of elements.
Checks, for the purposes of checking correctness,
that the correctness properties are preserved.
Method Summary | |
---|---|
void |
accept(Visitor<? super E> v)
Traverses each element of this collection, in the iteration order, on behalf of the visitor. |
void |
add(E value)
Inserts value into
the collection in an arbitrary location. |
void |
addAll(Collection<? extends E> c)
Adds all elements in c
to this collection. |
void |
checkRep()
|
void |
clear()
Removes all elements from this collection. |
boolean |
contains(E target)
Returns true if an element equivalent to target exists in this collection. |
void |
ensureCapacity(int capacity)
Increases the capacity of this collection, if necessary, to ensure that it can hold at least capacity elements. |
int |
getCapacity()
Returns the current capacity of this collection. |
Comparator<? super E> |
getComparator()
Returns the comparator for elements in this collection. |
E |
getEquivalentElement(E target)
Returns an element in the collection that is equivalent to target . |
Locator<E> |
getLocator(E target)
Returns a locator that has been initialized to an element equivalent to target . |
int |
getSize()
Returns the number of elements, size, in this collection. |
boolean |
isEmpty()
Returns true if this collection contains no elements, and otherwise returns false. |
Locator<E> |
iterator()
Returns a locator that has been initialized to FORE. |
boolean |
remove(E target)
Removes from this collection an arbitrary element equivalent to target , if such an element exists
in the collection. |
void |
retainAll(Collection<E> c)
Removes from this collection all elements for which there is no equivalent element in c . |
Object[] |
toArray()
Returns a Java primitive array of length n that holds the elements in this collection in the iteration order. |
E[] |
toArray(E[] a)
Fills a Java array with the elements in this collection in the iteration order, and returns the array that was filled. |
String |
toString()
Returns a string that includes each element in this collection (as produced by the toString method for that element), in the iteration order. |
void |
trimToSize()
Trims the capacity of an oversized collection to exactly hold its current elements. |
Method Detail |
---|
void checkRep()
void accept(Visitor<? super E> v)
void add(E value)
value
into
the collection in an arbitrary location. If a tracker is to be returned
then the method addTracked
which is part of the
Tracked
interface should be called instead.
An AtCapacityException
(an unchecked exception) is thrown when a bounded
collection is already at capacity.
void addAll(Collection<? extends E> c)
c
to this collection.
void clear()
boolean contains(E target)
void ensureCapacity(int capacity)
capacity
elements. For elastic implementations, this
method does nothing.
int getCapacity()
Integer.MAX_VALUE
is returned.
Comparator<? super E> getComparator()
E getEquivalentElement(E target)
target
. It
throws a NoSuchElementException
when there is no equivalent
element. The contains
method should be used to
determine if an element is in the collection.
Locator<E> getLocator(E target)
target
. Like the iterator
method, this method enables
navigation, but from a specified starting point. This method
throws a NoSuchElementException
if there is no equivalent element
in the collection.
int getSize()
boolean isEmpty()
Locator<E> iterator()
iterator
in interface Iterable<E>
boolean remove(E target)
target
, if such an element exists
in the collection. It
returns true
if an element was removed, and false
otherwise.
void retainAll(Collection<E> c)
c
. Thus, the elements that
remain are those in the intersection of c and this collection.
Object[] toArray()
E[] toArray(E[] a)
String toString()
toString
method for that element), in the iteration order.
toString
in class Object
void trimToSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |