util
Class Functional.Iteration<T>

java.lang.Object
  extended by util.Functional.Iteration<T>
Type Parameters:
T - The type of object over which to iterate.
All Implemented Interfaces:
Iterable<T>
Enclosing class:
Functional

public static final class Functional.Iteration<T>
extends Object
implements Iterable<T>

An adaptor for iterating in a foreach loop, given an iterator.

(Really, Iterator<T> should be a superinterface of Iterable<T>, or at least iterators ought to be allowed in foreach loops (since the meaning is obvious). Oh well.)


Field Summary
 Iterator<T> iter
          The iterator iterated over.
 
Constructor Summary
Functional.Iteration(Iterator<T> iter)
          Construct an Iterable for an Iterator.
 
Method Summary
 Iterator<T> iterator()
          Get back the iterator passed in to the constructor.
static
<T> Functional.Iteration<T>
with(Iterator<T> iter)
          Convenience constructor (to avoid giving an explicit type).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iter

public final Iterator<T> iter
The iterator iterated over.

Constructor Detail

Functional.Iteration

public Functional.Iteration(Iterator<T> iter)
Construct an Iterable for an Iterator.

Parameters:
iter - The Iterator to iterate over.
Method Detail

iterator

public Iterator<T> iterator()
Get back the iterator passed in to the constructor.

Specified by:
iterator in interface Iterable<T>
Returns:
The iterator.
See Also:
Iterable.iterator()

with

public static <T> Functional.Iteration<T> with(Iterator<T> iter)
Convenience constructor (to avoid giving an explicit type).

Type Parameters:
T - The type of object over which to iterate.
Parameters:
iter - The iterator to iterate over.
Returns:
An iterable iterating using the iterator.