net.sf.jga.fn.algorithm
Class TransformAdjacent<T,R>

java.lang.Object
  extended by net.sf.jga.fn.UnaryFunctor<java.util.Iterator<? extends T>,TransformAdjacentIterator<T,R>>
      extended by net.sf.jga.fn.algorithm.TransformAdjacent<T,R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class TransformAdjacent<T,R>
extends UnaryFunctor<java.util.Iterator<? extends T>,TransformAdjacentIterator<T,R>>

Applies a UnaryFunctor to every element in an iteration, and iterates over the results.

Copyright © 2004 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface TransformAdjacent.Visitor
          Interface for classes that may interpret an TransformAdjacent functor.
 
Constructor Summary
TransformAdjacent(BinaryFunctor<T,T,R> fn)
          Builds an TransformAdjacent functor that will apply the given functor to elements in an iteration.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(TransformAdjacent) method, if it implements the nested Visitor interface.
 TransformAdjacentIterator<T,R> fn(java.util.Iterator<? extends T> iterator)
          Apply the functor to each element in the iteration and return an iterator over the results
 BinaryFunctor<T,T,R> getFunction()
          Returns the functor used to process elements in an iteration.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, compose, compose, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformAdjacent

public TransformAdjacent(BinaryFunctor<T,T,R> fn)
Builds an TransformAdjacent functor that will apply the given functor to elements in an iteration.

Throws:
java.lang.IllegalArgumentException - if the functor is null
Method Detail

getFunction

public BinaryFunctor<T,T,R> getFunction()
Returns the functor used to process elements in an iteration.


fn

public TransformAdjacentIterator<T,R> fn(java.util.Iterator<? extends T> iterator)
Apply the functor to each element in the iteration and return an iterator over the results

Specified by:
fn in class UnaryFunctor<java.util.Iterator<? extends T>,TransformAdjacentIterator<T,R>>
Returns:
an iterator over the results of the transformation

accept

public void accept(Visitor v)
Calls the Visitor's visit(TransformAdjacent) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class UnaryFunctor<java.util.Iterator<? extends T>,TransformAdjacentIterator<T,R>>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2005 David A. Hall. All Rights Reserved.