edu.rice.cs.plt.iter
Class MappedIterator<S,T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.MappedIterator<S,T>
All Implemented Interfaces:
Composite, java.util.Iterator<T>

public class MappedIterator<S,T>
extends java.lang.Object
implements java.util.Iterator<T>, Composite

An Iterator that applies a provided mapping lambda to each member of a source iterator. remove() simply delegates to the source iterator.


Constructor Summary
MappedIterator(java.util.Iterator<? extends S> source, Lambda<? super S,? extends T> map)
           
 
Method Summary
 int compositeHeight()
          Get the maximum path length from this node to a leaf.
 int compositeSize()
          Get the number of nodes in the tree rooted at this node.
 boolean hasNext()
           
static
<S,T> MappedIterator<S,T>
make(java.util.Iterator<? extends S> source, Lambda<? super S,? extends T> map)
          Call the constructor (allows the type arguments to be inferred)
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappedIterator

public MappedIterator(java.util.Iterator<? extends S> source,
                      Lambda<? super S,? extends T> map)
Method Detail

compositeHeight

public int compositeHeight()
Description copied from interface: Composite
Get the maximum path length from this node to a leaf.

Specified by:
compositeHeight in interface Composite

compositeSize

public int compositeSize()
Description copied from interface: Composite
Get the number of nodes in the tree rooted at this node. Always 1 or greater.

Specified by:
compositeSize in interface Composite

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>

make

public static <S,T> MappedIterator<S,T> make(java.util.Iterator<? extends S> source,
                                             Lambda<? super S,? extends T> map)
Call the constructor (allows the type arguments to be inferred)