Class AverageClosure<T>

java.lang.Object
microsim.collection.AverageClosure<T>
Type Parameters:
T - A generic agent type.
All Implemented Interfaces:
org.apache.commons.collections4.Closure<T>

public abstract class AverageClosure<T> extends Object implements org.apache.commons.collections4.Closure<T>
A generic implementation of Closure, calculates some average.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final jamjam.Sum.Accumulator
     
    protected long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double value)
    Adds a value to the total sum and increments the total number of values by 1.
    void
    add(double @NonNull [] value)
    Adds together all values in the array and stores both the total sum and the total number of elements to date in accumulator and count, respectively.
    void
    add(@NonNull DoubleStream value)
    Adds all values from DoubleStream to the total sum and increments the total number by the corresponding stream length.
    double
    Calculates the average accumulated value.
    double
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.commons.collections4.Closure

    execute
  • Field Details

    • accumulator

      protected final jamjam.Sum.Accumulator accumulator
    • count

      protected long count
  • Constructor Details

    • AverageClosure

      public AverageClosure()
  • Method Details

    • getSum

      public double getSum()
    • getAverage

      public double getAverage()
      Calculates the average accumulated value.
      Returns:
      the average value.
    • add

      public void add(double value)
      Adds a value to the total sum and increments the total number of values by 1.
      Parameters:
      value - The value to be added to the sum.
    • add

      public void add(double @NonNull [] value)
      Adds together all values in the array and stores both the total sum and the total number of elements to date in accumulator and count, respectively.
      Throws:
      NullPointerException - when value is null.
      See Also:
    • add

      public void add(@NonNull @NonNull DoubleStream value)
      Adds all values from DoubleStream to the total sum and increments the total number by the corresponding stream length.
      Throws:
      NullPointerException - when value is null.
      See Also: