de.lmu.ifi.dbs.elki.utilities.iterator
Class IterableIteratorAdapter<T>

java.lang.Object
  extended by 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)) {
   // ...
 }
 


Field Summary
(package private)  Iterator<T> iter
          Parent Iterator
(package private)  Iterable<T> parent
          Parent Iterable
 
Constructor Summary
IterableIteratorAdapter(Iterable<T> parent)
          Constructor from an Iterable (preferred).
IterableIteratorAdapter(Iterator<T> iter)
          Constructor from an Iterator.
 
Method Summary
 boolean hasNext()
           
 Iterator<T> iterator()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

Iterable<T> parent
Parent Iterable


iter

Iterator<T> iter
Parent Iterator

Constructor Detail

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
Method Detail

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>

Release 0.4.0 (2011-09-20_1324)