|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectnet.tsz.afinal.core.AbstractCollection<E>
public abstract class AbstractCollection<E>
Class AbstractCollection is an abstract implementation of the Collection interface. A subclass must implement the abstract methods iterator() and size() to create an immutable collection. To create a
modifiable collection it's necessary to override the add() method that
currently throws an UnsupportedOperationException.
| 方法摘要 | ||
|---|---|---|
boolean |
add(E object)
|
|
boolean |
addAll(java.util.Collection<? extends E> collection)
Attempts to add all of the objects contained in collection
to the contents of this Collection (optional). |
|
void |
clear()
Removes all elements from this Collection, leaving it empty (optional). |
|
boolean |
contains(java.lang.Object object)
Tests whether this Collection contains the specified object. |
|
boolean |
containsAll(java.util.Collection<?> collection)
Tests whether this Collection contains all objects contained in the
specified Collection. |
|
boolean |
isEmpty()
Returns if this Collection contains no elements. |
|
abstract java.util.Iterator<E> |
iterator()
Returns an instance of Iterator that may be used to access the
objects contained by this Collection. |
|
boolean |
remove(java.lang.Object object)
Removes one instance of the specified object from this Collection if one
is contained (optional). |
|
boolean |
removeAll(java.util.Collection<?> collection)
Removes all occurrences in this Collection of each object in the
specified Collection (optional). |
|
boolean |
retainAll(java.util.Collection<?> collection)
Removes all objects from this Collection that are not also found in the
Collection passed (optional). |
|
abstract int |
size()
Returns a count of how many objects this Collection contains. |
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] contents)
|
|
java.lang.String |
toString()
Returns the string representation of this Collection. |
|
| 从类 java.lang.Object 继承的方法 |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 从接口 java.util.Collection 继承的方法 |
|---|
equals, hashCode |
| 方法详细信息 |
|---|
public boolean add(E object)
java.util.Collection<E> 中的 addpublic boolean addAll(java.util.Collection<? extends E> collection)
collection
to the contents of this Collection (optional). This implementation
iterates over the given Collection and calls add for each
element. If any of these calls return true, then true is
returned as result of this method call, false otherwise. If this
Collection does not support adding elements, an UnsupportedOperationException is thrown.
If the passed Collection is changed during the process of adding elements
to this Collection, the behavior depends on the behavior of the passed
Collection.
java.util.Collection<E> 中的 addAllcollection - the collection of objects.
true if this Collection is modified, false
otherwise.
java.lang.UnsupportedOperationException - if adding to this Collection is not supported.
java.lang.ClassCastException - if the class of an object is inappropriate for this
Collection.
java.lang.IllegalArgumentException - if an object cannot be added to this Collection.
java.lang.NullPointerException - if collection is null, or if it contains
null elements and this Collection does not support
such elements.public void clear()
Collection, leaving it empty (optional).
This implementation iterates over this Collection and calls the remove method on each element. If the iterator does not support removal
of elements, an UnsupportedOperationException is thrown.
Concrete implementations usually can clear a Collection more efficiently
and should therefore overwrite this method.
java.util.Collection<E> 中的 clearjava.lang.UnsupportedOperationException - it the iterator does not support removing elements from
this Collectioniterator(),
isEmpty(),
size()public boolean contains(java.lang.Object object)
Collection contains the specified object. This
implementation iterates over this Collection and tests, whether any
element is equal to the given object. If object != null then
object.equals(e) is called for each element e returned by
the iterator until the element is found. If object == null then
each element e returned by the iterator is compared with the test
e == null.
java.util.Collection<E> 中的 containsobject - the object to search for.
true if object is an element of this Collection, false otherwise.
java.lang.ClassCastException - if the object to look for isn't of the correct type.
java.lang.NullPointerException - if the object to look for is null and this
Collection doesn't support null elements.public boolean containsAll(java.util.Collection<?> collection)
Collection contains all objects contained in the
specified Collection. This implementation iterates over the specified
Collection. If one element returned by the iterator is not contained in
this Collection, then false is returned; true otherwise.
java.util.Collection<E> 中的 containsAllcollection - the collection of objects.
true if all objects in the specified Collection are
elements of this Collection, false otherwise.
java.lang.ClassCastException - if one or more elements of collection isn't of the
correct type.
java.lang.NullPointerException - if collection contains at least one null
element and this Collection doesn't support null
elements.
java.lang.NullPointerException - if collection is null.public boolean isEmpty()
Collection contains no elements. This implementation
tests, whether size returns 0.
java.util.Collection<E> 中的 isEmptytrue if this Collection has no elements, false
otherwise.size()public abstract java.util.Iterator<E> iterator()
Iterator that may be used to access the
objects contained by this Collection. The order in which the elements are
returned by the Iterator is not defined unless the instance of the
Collection has a defined order. In that case, the elements are returned in that order.
In this class this method is declared abstract and has to be implemented
by concrete Collection implementations.
java.lang.Iterable<E> 中的 iteratorjava.util.Collection<E> 中的 iteratorCollection contents.public boolean remove(java.lang.Object object)
Collection if one
is contained (optional). This implementation iterates over this
Collection and tests for each element e returned by the iterator,
whether e is equal to the given object. If object != null
then this test is performed using object.equals(e), otherwise
using object == null. If an element equal to the given object is
found, then the remove method is called on the iterator and
true is returned, false otherwise. If the iterator does
not support removing elements, an UnsupportedOperationException
is thrown.
java.util.Collection<E> 中的 removeobject - the object to remove.
true if this Collection is modified, false
otherwise.
java.lang.UnsupportedOperationException - if removing from this Collection is not supported.
java.lang.ClassCastException - if the object passed is not of the correct type.
java.lang.NullPointerException - if object is null and this Collection
doesn't support null elements.public boolean removeAll(java.util.Collection<?> collection)
Collection of each object in the
specified Collection (optional). After this method returns none of the
elements in the passed Collection can be found in this Collection
anymore.
This implementation iterates over this Collection and tests for each
element e returned by the iterator, whether it is contained in
the specified Collection. If this test is positive, then the remove method is called on the iterator. If the iterator does not
support removing elements, an UnsupportedOperationException is
thrown.
java.util.Collection<E> 中的 removeAllcollection - the collection of objects to remove.
true if this Collection is modified, false
otherwise.
java.lang.UnsupportedOperationException - if removing from this Collection is not supported.
java.lang.ClassCastException - if one or more elements of collection isn't of the
correct type.
java.lang.NullPointerException - if collection contains at least one null
element and this Collection doesn't support null
elements.
java.lang.NullPointerException - if collection is null.public boolean retainAll(java.util.Collection<?> collection)
Collection that are not also found in the
Collection passed (optional). After this method returns this Collection
will only contain elements that also can be found in the Collection
passed to this method.
This implementation iterates over this Collection and tests for each
element e returned by the iterator, whether it is contained in
the specified Collection. If this test is negative, then the remove method is called on the iterator. If the iterator does not
support removing elements, an UnsupportedOperationException is
thrown.
java.util.Collection<E> 中的 retainAllcollection - the collection of objects to retain.
true if this Collection is modified, false
otherwise.
java.lang.UnsupportedOperationException - if removing from this Collection is not supported.
java.lang.ClassCastException - if one or more elements of collection
isn't of the correct type.
java.lang.NullPointerException - if collection contains at least one
null element and this Collection doesn't support
null elements.
java.lang.NullPointerException - if collection is null.public abstract int size()
Collection contains.
In this class this method is declared abstract and has to be implemented
by concrete Collection implementations.
java.util.Collection<E> 中的 sizeCollection contains, or Integer.MAX_VALUE
if there are more than Integer.MAX_VALUE elements in this
Collection.public java.lang.Object[] toArray()
java.util.Collection<E> 中的 toArraypublic <T> T[] toArray(T[] contents)
java.util.Collection<E> 中的 toArraypublic java.lang.String toString()
Collection. The presentation
has a specific format. It is enclosed by square brackets ("[]"). Elements
are separated by ', ' (comma and space).
java.lang.Object 中的 toStringCollection.
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||