DthingApi
|
Public Member Functions | |
boolean | add (E object) |
boolean | addAll (Collection<? extends E > collection) |
void | clear () |
boolean | contains (Object object) |
boolean | containsAll (Collection<?> collection) |
boolean | equals (Object object) |
int | hashCode () |
boolean | isEmpty () |
Iterator< E > | iterator () |
boolean | remove (Object object) |
boolean | removeAll (Collection<?> collection) |
boolean | retainAll (Collection<?> collection) |
int | size () |
Object [] | toArray () |
is the root of the collection hierarchy. It defines operations on data collections and the behavior that they will have in all implementations of
s.
All direct or indirect implementations of
should implement at least two constructors. One with no parameters which creates an empty collection and one with a parameter of type
. This second constructor can be used to create a collection of different type as the initial collection but with the same elements. Implementations of
cannot be forced to implement these two constructors but at least all implementations under
do.
Methods that change the content of a collection throw an
if the underlying collection does not support that operation, though it's not mandatory to throw such an
in cases where the requested operation would not change the collection. In these cases it's up to the implementation whether it throws an
or not.
Methods marked with (optional) can throw an
if the underlying collection doesn't support that method.
boolean java.util.Collection< E >.add | ( | E | object | ) |
Attempts to add
to the contents of this
(optional).
After this method finishes successfully it is guaranteed that the object is contained in the collection.
If the collection was modified it returns
,
if no changes were made.
An implementation of
may narrow the set of accepted objects, but it has to specify this in the documentation. If the object to be added does not meet this restriction, then an
is thrown.
If a collection does not yet contain an object that is to be added and adding the object fails, this method must throw an appropriate unchecked Exception. Returning false is not permitted in this case because it would violate the postcondition that the element will be part of the collection after this method finishes.
object | the object to add. |
UnsupportedOperationException | if adding to this Collection |
ClassCastException | if the class of the object is inappropriate for this collection. |
IllegalArgumentException | if the object cannot be added to this Collection |
NullPointerException | if null elements cannot be added to the Collection |
Implemented in java.util.AbstractList< E >, java.util.Vector< E >, java.util.Queue< E >, java.util.ArrayList< E >, java.util.HashSet< E >, java.util.List< E >, java.util.AbstractQueue< E >, java.util.Set< E >, and java.util.AbstractCollection< E >.
boolean java.util.Collection< E >.addAll | ( | Collection<? extends E > | collection | ) |
Attempts to add all of the objects contained in
to the contents of this
(optional). If the passed
is changed during the process of adding elements to this
, the behavior is not defined.
collection | the Collection |
UnsupportedOperationException | if adding to this Collection |
ClassCastException | if the class of an object is inappropriate for this Collection |
IllegalArgumentException | if an object cannot be added to this Collection |
NullPointerException | if collection null null Collection |
Implemented in java.util.Vector< E >, java.util.ArrayList< E >, java.util.AbstractQueue< E >, java.util.List< E >, java.util.AbstractCollection< E >, and java.util.Set< E >.
void java.util.Collection< E >.clear | ( | ) |
Removes all elements from this
, leaving it empty (optional).
UnsupportedOperationException | if removing from this Collection |
Implemented in java.util.AbstractList< E >, java.util.ArrayList< E >, java.util.Vector< E >, java.util.List< E >, java.util.AbstractQueue< E >, java.util.AbstractCollection< E >, java.util.HashSet< E >, and java.util.Set< E >.
boolean java.util.Collection< E >.contains | ( | Object | object | ) |
Tests whether this
contains the specified object. Returns
if and only if at least one element
in this
meets following requirement:
.
object | the object to search for. |
ClassCastException | if the object to look for isn't of the correct type. |
NullPointerException | if the object to look for is null Collection null |
Implemented in java.util.ArrayList< E >, java.util.Vector< E >, java.util.List< E >, java.util.AbstractCollection< E >, java.util.HashSet< E >, and java.util.Set< E >.
boolean java.util.Collection< E >.containsAll | ( | Collection<?> | collection | ) |
Tests whether this
contains all objects contained in the specified
. If an element
is contained several times in the specified
, the method returns
even if
is contained only once in this
.
collection | the collection of objects. |
ClassCastException | if one or more elements of collection |
NullPointerException | if collection null Collection null |
NullPointerException | if collection null |
Implemented in java.util.Vector< E >, java.util.AbstractCollection< E >, java.util.List< E >, and java.util.Set< E >.
boolean java.util.Collection< E >.equals | ( | Object | object | ) |
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
object | the object to compare with this object. |
Implemented in java.util.ArrayList< E >, java.util.AbstractList< E >, java.util.Vector< E >, java.util.List< E >, java.util.Set< E >, and java.util.AbstractSet< E >.
int java.util.Collection< E >.hashCode | ( | ) |
Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.
Implemented in java.util.ArrayList< E >, java.util.AbstractList< E >, java.util.Vector< E >, java.util.List< E >, java.util.Set< E >, and java.util.AbstractSet< E >.
boolean java.util.Collection< E >.isEmpty | ( | ) |
Returns if this
contains no elements.
Implemented in java.util.Vector< E >, java.util.ArrayList< E >, java.util.List< E >, java.util.AbstractCollection< E >, java.util.HashSet< E >, and java.util.Set< E >.
Iterator<E> java.util.Collection< E >.iterator | ( | ) |
Returns an instance of Iterator that may be used to access the objects contained by this
. The order in which the elements are returned by the iterator is not defined. Only if the instance of the
has a defined order the elements are returned in that order.
Implemented in java.util.AbstractList< E >, java.util.ArrayList< E >, java.util.List< E >, java.util.AbstractCollection< E >, java.util.HashSet< E >, and java.util.Set< E >.
boolean java.util.Collection< E >.remove | ( | Object | object | ) |
Removes one instance of the specified object from this
if one is contained (optional). The element
that is removed complies with
.
object | the object to remove. |
UnsupportedOperationException | if removing from this Collection |
ClassCastException | if the object passed is not of the correct type. |
NullPointerException | if object null Collection null |
Implemented in java.util.Vector< E >, java.util.ArrayList< E >, java.util.List< E >, java.util.AbstractCollection< E >, java.util.HashSet< E >, and java.util.Set< E >.
boolean java.util.Collection< E >.removeAll | ( | Collection<?> | collection | ) |
Removes all occurrences in this
of each object in the specified
(optional). After this method returns none of the elements in the passed
can be found in this
anymore.
collection | the collection of objects to remove. |
UnsupportedOperationException | if removing from this Collection |
ClassCastException | if one or more elements of collection |
NullPointerException | if collection null Collection null |
NullPointerException | if collection null |
Implemented in java.util.Vector< E >, java.util.AbstractCollection< E >, java.util.List< E >, java.util.Set< E >, and java.util.AbstractSet< E >.
boolean java.util.Collection< E >.retainAll | ( | Collection<?> | collection | ) |
Removes all objects from this
that are not also found in the
passed (optional). After this method returns this
will only contain elements that also can be found in the
passed to this method.
collection | the collection of objects to retain. |
UnsupportedOperationException | if removing from this Collection |
ClassCastException | if one or more elements of collection |
NullPointerException | if collection null Collection null |
NullPointerException | if collection null |
Implemented in java.util.Vector< E >, java.util.AbstractCollection< E >, java.util.List< E >, and java.util.Set< E >.
int java.util.Collection< E >.size | ( | ) |
Returns a count of how many objects this
contains.
Implemented in java.util.Vector< E >, java.util.AbstractCollection< E >, java.util.ArrayList< E >, java.util.List< E >, java.util.Set< E >, and java.util.HashSet< E >.
Object [] java.util.Collection< E >.toArray | ( | ) |
Returns a new array containing all elements contained in this
.
If the implementation has ordered elements it will return the element array in the same order as an iterator would return them.
The array returned does not reflect any changes of the
. A new array is created even if the underlying data structure is already an array.
Implemented in java.util.Vector< E >, java.util.ArrayList< E >, java.util.AbstractCollection< E >, java.util.List< E >, and java.util.Set< E >.