public class Averager
extends java.lang.Object
Constructor and Description |
---|
Averager(int windowSize)
Creates a "windowed" averaging object.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the averaging "window" back to its initial state.
|
long |
enter(long val)
Enters the new value into the averaging "window".
|
long |
getAverage()
Returns the current average of values in the "window".
|
public Averager(int windowSize)
windowSize
- the number of values to track and use when
computing the average. If the value is not greater than zero
then a runtime exception is thrown.public void clear()
public long enter(long val)
val
- the value to be entered.public long getAverage()