net.sf.jga.fn.arithmetic
Class Average<T extends java.lang.Number>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.UnaryFunctor<java.util.Iterator<T>,T>
          extended by net.sf.jga.fn.arithmetic.Average<T>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class Average<T extends java.lang.Number>
extends UnaryFunctor<java.util.Iterator<T>,T>

Averages numeric values in an iteration.

Copyright © 2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Average.Visitor
          Interface for classes that may interpret an Average functor.
 
Constructor Summary
Average(java.lang.Class<T> type)
          Builds a functor that averages numeric values in an iteration
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Average) method, if it implements the nested Visitor interface.
 T fn(java.util.Iterator<T> iterator)
          Returns the average of the elements in the iteration
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Average

public Average(java.lang.Class<T> type)
Builds a functor that averages numeric values in an iteration

Method Detail

fn

public T fn(java.util.Iterator<T> iterator)
Returns the average of the elements in the iteration

Specified by:
fn in class UnaryFunctor<java.util.Iterator<T extends java.lang.Number>,T extends java.lang.Number>

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<T extends java.lang.Number>

toString

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


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