net.sf.jga.fn.algorithm

Class TransformUnary<T,R>

public class TransformUnary<T,R> extends AbstractUnaryFunctor<Iterator<? extends T>,TransformIterator<T,R>> implements Serializable

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

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceTransformUnary.Visitor
Interface for classes that may interpret an TransformUnary functor.
Constructor Summary
TransformUnary(UnaryFunctor<T,R> fn)
Builds an TransformUnary functor that will apply the given functor to elements in an iteration.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(TransformUnary) method, if it implements the nested Visitor interface.
TransformIterator<T,R>fn(Iterator<? extends T> iterator)
Apply the functor to each element in the iteration and return an iterator over the results
UnaryFunctor<T,R>getFunction()
Returns the functor used to process elements in an iteration.
StringtoString()

Constructor Detail

TransformUnary

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

Throws: IllegalArgumentException if the functor is null

Method Detail

accept

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

fn

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

Returns: an iterator over the results of the transformation

getFunction

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

toString

public String toString()