|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jga.fn.UnaryFunctor<java.util.Iterator<? extends T>,R>
net.sf.jga.fn.algorithm.ForEach<T,R>
public class ForEach<T,R>
Applies a UnaryFunctor to each element in an iteration, and returns the final result. Each element in the iteration is passed to the functor in turn. The result of the final call to the functor is returned. If the iteration was empty, then the result of this function is null.
Copyright © 2003 David A. Hall
| Nested Class Summary | |
|---|---|
static interface |
ForEach.Visitor
Interface for classes that may interpret an ForEach functor. |
| Constructor Summary | |
|---|---|
ForEach(UnaryFunctor<T,R> fn)
Builds a ForEach functor that will use the given functor to process elements in an iteration. |
|
| Method Summary | |
|---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(ForEach) method, if it
implements the nested Visitor interface. |
R |
fn(java.util.Iterator<? extends T> iterator)
Apply the functor to each element in the iteration and return the final result. |
UnaryFunctor<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 |
|---|
public ForEach(UnaryFunctor<T,R> fn)
java.lang.IllegalArgumentException - if the functor is null| Method Detail |
|---|
public UnaryFunctor<T,R> getFunction()
public R fn(java.util.Iterator<? extends T> iterator)
fn in class UnaryFunctor<java.util.Iterator<? extends T>,R>public void accept(Visitor v)
visit(ForEach) method, if it
implements the nested Visitor interface.
accept in interface Visitableaccept in class UnaryFunctor<java.util.Iterator<? extends T>,R>public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||