de.lmu.ifi.dbs.elki.utilities.iterator
Class IterableIteratorAdapter<T>
java.lang.Object
de.lmu.ifi.dbs.elki.utilities.iterator.IterableIteratorAdapter<T>
- Type Parameters:
T
- object type
- All Implemented Interfaces:
- IterableIterator<T>, Iterable<T>, Iterator<T>
public final class IterableIteratorAdapter<T>
- extends Object
- implements IterableIterator<T>
This interface can convert an Iterable
to an Iterator
or the
other way round. Note that Iterator
to Iterable
is for
single-shot use only. This allows for using an Iterator in for:
for (Type var : new IterableIterator<Type>(iterator)) {
// ...
}
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parent
Iterable<T> parent
- Parent Iterable
iter
Iterator<T> iter
- Parent Iterator
IterableIteratorAdapter
public IterableIteratorAdapter(Iterable<T> parent)
- Constructor from an Iterable (preferred).
- Parameters:
parent
- Iterable parent
IterableIteratorAdapter
public IterableIteratorAdapter(Iterator<T> iter)
- Constructor from an Iterator.
If possible, wrap an Iterable object.
- Parameters:
iter
- Iterator
iterator
public Iterator<T> iterator()
- Specified by:
iterator
in interface Iterable<T>
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface Iterator<T>
next
public T next()
- Specified by:
next
in interface Iterator<T>
remove
public void remove()
- Specified by:
remove
in interface Iterator<T>