public abstract class AbstractIterationSet<E> extends AbstractSet<E>
Set implementations for which calculating size() requires
an iteration through all of the set's elements to count them.
Superclass methods in AbstractSet that rely on size() are overridden with alternate
implementations that avoid the use of size() when possible.
For a read-only implementation, subclasses should implement contains() and iterator().
For a mutable implementation, subclasses should also implement add(), remove(),
and clear(), and make the iterator() mutable.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIterationSet() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Overridden in
AbstractIterationSet to minimize the use of size(). |
int |
hashCode() |
boolean |
isEmpty()
Overridden in
AbstractIterationSet to minimize the use of size(). |
int |
size()
Calculate size.
|
Object[] |
toArray()
Overridden in
AbstractIterationSet to minimize the use of size(). |
<T> T[] |
toArray(T[] array)
Overridden in
AbstractIterationSet to minimize the use of size(). |
removeAlladd, addAll, clear, contains, containsAll, iterator, remove, retainAll, toStringpublic int size()
The implementation in AbstractIterationSet iterates through all of the elements.
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean equals(Object obj)
AbstractIterationSet to minimize the use of size().equals in interface Collection<E>equals in interface Set<E>equals in class AbstractSet<E>public int hashCode()
hashCode in interface Collection<E>hashCode in interface Set<E>hashCode in class AbstractSet<E>public boolean isEmpty()
AbstractIterationSet to minimize the use of size().isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public Object[] toArray()
AbstractIterationSet to minimize the use of size().toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] array)
AbstractIterationSet to minimize the use of size().toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>Copyright © 2016. All rights reserved.