Package com.macrofocus.treemap.voronoi
Class MovingAverager
- java.lang.Object
-
- com.macrofocus.treemap.voronoi.MovingAverager
-
public class MovingAverager extends java.lang.Object
Class for calculating a moving average.
-
-
Constructor Summary
Constructors Constructor Description MovingAverager(int nValues)
Creates a new MovingAverager.
-
Method Summary
All Methods Instance Methods Concrete Methods 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.
-
-
-
Method Detail
-
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
-
-