net.sf.jga.fn.algorithm
Class TransformBinary<T1,T2,R>

java.lang.Object
  extended by net.sf.jga.fn.BinaryFunctor<java.util.Iterator<? extends T1>,java.util.Iterator<? extends T2>,java.util.Iterator<R>>
      extended by net.sf.jga.fn.algorithm.TransformBinary<T1,T2,R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class TransformBinary<T1,T2,R>
extends BinaryFunctor<java.util.Iterator<? extends T1>,java.util.Iterator<? extends T2>,java.util.Iterator<R>>

Applies a BinaryFunctor to corresponding elements in a pair of iterations, and iterates over the results.

Copyright © 2003 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface TransformBinary.Visitor
          Interface for classes that may interpret an Transform functor.
 
Constructor Summary
TransformBinary(BinaryFunctor<T1,T2,R> fn)
          Builds an TransformBinary functor that will use the given functor to process corresponding elements in a pair of iterations.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Transform) method, if it implements the nested Visitor interface.
 java.util.Iterator<R> fn(java.util.Iterator<? extends T1> i1, java.util.Iterator<? extends T2> i2)
          Apply the functor to corresponding elements in the iterations and return an iterator over the results.
 BinaryFunctor<T1,T2,R> getFunction()
          Returns the functor used to process elements in a pair of iterations.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.BinaryFunctor
bind, bind1st, bind2nd, compose, compose, distribute, generate, generate1st, generate2nd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformBinary

public TransformBinary(BinaryFunctor<T1,T2,R> fn)
Builds an TransformBinary functor that will use the given functor to process corresponding elements in a pair of iterations.

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

getFunction

public BinaryFunctor<T1,T2,R> getFunction()
Returns the functor used to process elements in a pair of iterations.


fn

public java.util.Iterator<R> fn(java.util.Iterator<? extends T1> i1,
                                java.util.Iterator<? extends T2> i2)
Apply the functor to corresponding elements in the iterations and return an iterator over the results. The resulting iterator will contain the same number of elements as the shorter of the two input iterators (if one of the input iterators is empty, then the resulting iterator will also be empty).

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

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class BinaryFunctor<java.util.Iterator<? extends T1>,java.util.Iterator<? extends T2>,java.util.Iterator<R>>

toString

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


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