T
- The element type of the iterator and the collectionpublic class IteratorCollection<T> extends AbstractCollection<T>
Collection
that lazily reads its elements from an
Iterator
.
In other words, you can call iterator()
as often as you want, but the
IteratorCollection
will iterate over its delegate only once.
Constructor and Description |
---|
IteratorCollection(Iterator iterator) |
Modifier and Type | Method and Description |
---|---|
Iterator<T> |
iterator() |
int |
size() |
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
public IteratorCollection(Iterator iterator)
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in class AbstractCollection<T>
public int size()
size
in interface Collection<T>
size
in class AbstractCollection<T>
Copyright © 2001–2016. All rights reserved.