# Class MovingAverager

java.lang.Object
com.treemap.swing.voronoi.MovingAverager

public class MovingAverager extends Object
Class for calculating a moving average.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MovingAverager(int nValues)`
  Creates a new MovingAverager.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(double value)`
  Adds a new value to the ring buffer.
  `double`
  `getAverage()`
  Calculates and returns the average of the proviously added values.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### MovingAverager

    public MovingAverager(int nValues)
    Creates a new MovingAverager.
    Parameters:
      `nValues` - number of values to use for the moving average

- ## Method Details

  - ### add

    public void add(double value)
    Adds a new value to the ring buffer.
    Parameters:
      `value` - the new value

  - ### getAverage

    public double getAverage()
    Calculates and returns the average of the proviously added values. Maximal number of previous values are defined by the initial nValues parameter of the contructor.
    Returns:
      the average value