net.sf.jga.fn.algorithm

Class TransformBinary<T1,T2,R>

public class TransformBinary<T1,T2,R> extends AbstractBinaryFunctor<Iterator<? extends T1>,Iterator<? extends T2>,Iterator<R>> implements Serializable

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

Nested Class Summary
interfaceTransformBinary.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
voidaccept(Visitor v)
Calls the Visitor's visit(Transform) method, if it implements the nested Visitor interface.
Iterator<R>fn(Iterator<? extends T1> i1, 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.
StringtoString()

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: IllegalArgumentException if the functor is null

Method Detail

accept

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

fn

public Iterator<R> fn(Iterator<? extends T1> i1, 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).

Returns: an iterator over the results of the transformation

getFunction

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

toString

public String toString()