Methods Summary |
---|
public boolean | add(E object)Attempts to add {@code object} to the contents of this
{@code Collection} (optional).
After this method finishes successfully it is guaranteed that the object
is contained in the collection.
If the collection was modified it returns {@code true}, {@code false} if
no changes were made.
An implementation of {@code Collection} 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
{@code IllegalArgumentException} 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.
|
public boolean | addAll(java.util.Collection collection)Attempts to add all of the objects contained in {@code Collection}
to the contents of this {@code Collection} (optional). If the passed {@code Collection}
is changed during the process of adding elements to this {@code Collection}, the
behavior is not defined.
|
public void | clear()Removes all elements from this {@code Collection}, leaving it empty (optional).
|
public boolean | contains(java.lang.Object object)Tests whether this {@code Collection} contains the specified object. Returns
{@code true} if and only if at least one element {@code elem} in this
{@code Collection} meets following requirement:
{@code (object==null ? elem==null : object.equals(elem))}.
|
public boolean | containsAll(java.util.Collection collection)Tests whether this {@code Collection} contains all objects contained in the
specified {@code Collection}. If an elemenet {@code elem} is contained several
times in the specified {@code Collection}, the method returns {@code true} even
if {@code elem} is contained only once in this {@code Collection}.
|
public boolean | equals(java.lang.Object object)Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
public int | hashCode()Returns an integer hash code for the receiver. Objects which are equal
return the same value for this method.
|
public boolean | isEmpty()Returns if this {@code Collection} contains no elements.
|
public java.util.Iterator | iterator()Returns an instance of {@link Iterator} that may be used to access the
objects contained by this {@code Collection}. The order in which the elements are
returned by the iterator is not defined. Only if the instance of the
{@code Collection} has a defined order the elements are returned in that order.
|
public boolean | remove(java.lang.Object object)Removes one instance of the specified object from this {@code Collection} if one
is contained (optional). The element {@code elem} that is removed
complies with {@code (object==null ? elem==null : object.equals(elem)}.
|
public boolean | removeAll(java.util.Collection collection)Removes all occurrences in this {@code Collection} of each object in the
specified {@code Collection} (optional). After this method returns none of the
elements in the passed {@code Collection} can be found in this {@code Collection}
anymore.
|
public boolean | retainAll(java.util.Collection collection)Removes all objects from this {@code Collection} that are not also found in the
{@code Collection} passed (optional). After this method returns this {@code Collection}
will only contain elements that also can be found in the {@code Collection}
passed to this method.
|
public int | size()Returns a count of how many objects this {@code Collection} contains.
|
public java.lang.Object[] | toArray()Returns a new array containing all elements contained in this {@code Collection}.
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 {@code Collection}. A new
array is created even if the underlying data structure is already an
array.
|
public T[] | toArray(T[] array)Returns an array containing all elements contained in this {@code Collection}. If
the specified array is large enough to hold the elements, the specified
array is used, otherwise an array of the same type is created. If the
specified array is used and is larger than this {@code Collection}, the array
element following the {@code Collection} elements is set to null.
If the implementation has ordered elements it will return the element
array in the same order as an iterator would return them.
{@code toArray(new Object[0])} behaves exactly the same way as
{@code toArray()} does.
|