public interface ObjectCollection<K> extends java.util.Collection<K>, ObjectIterable<K>
Collection
; provides some additional methods
that use polymorphism to avoid (un)boxing.
Additionally, this class defines strengthens (again) iterator()
.
This interface specifies reference equality semantics (members will be compared equal with
==
instead of equals
), which may result in breaks in contract
if attempted to be used with non reference-equality semantics based Collection
s. For example, a
aReferenceCollection.equals(aObjectCollection)
may return different a different result then
aObjectCollection.equals(aReferenceCollection)
, in violation of equals
's
contract requiring it being symmetric.
Collection
Modifier and Type | Method and Description |
---|---|
ObjectIterator<K> |
iterator()
Returns a type-specific iterator on the elements of this collection.
|
default ObjectSpliterator<K> |
spliterator()
Returns a type-specific spliterator on the elements of this collection.
|
ObjectIterator<K> iterator()
iterator
in interface java.util.Collection<K>
iterator
in interface java.lang.Iterable<K>
iterator
in interface ObjectIterable<K>
Iterable.iterator()
Iterable.iterator()
, which was already
strengthened in the corresponding type-specific class,
but was weakened by the fact that this interface extends Collection
.default ObjectSpliterator<K> spliterator()
See Collection.spliterator()
for more documentation on the requirements
of the returned spliterator.
spliterator
in interface java.util.Collection<K>
spliterator
in interface java.lang.Iterable<K>
spliterator
in interface ObjectIterable<K>
Collection.spliterator()
.
Also, this is generally the only spliterator
method subclasses should override.
Spliterator
for documentation on what binding policies mean)
that wraps this instance's type specific iterator()
.
Additionally, it reports Spliterator.SIZED
Iterator
is an inherently linear API, the returned spliterator will yield limited performance gains
when run in parallel contexts, as the returned spliterator's
trySplit()
will have linear runtime.