public class MovingAverage<TYPE> extends Object implements IMovingAverage<TYPE>
| Constructor and Description |
|---|
MovingAverage(IAveragator<TYPE> averagator) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(TYPE item)
Add another item into the moving average.
|
TYPE |
getAverage()
Returns an average of all items stored.
|
int |
getCurrentLength()
Return current number of items that are used to compute the average returned
via
IMovingAverage.getAverage(). |
int |
getMaxLength()
Return max number of consecutive items (added via
IMovingAverage.add(Object) that are used to
compute the average returned via IMovingAverage.getAverage(). |
boolean |
isEnoughValues()
Whether the object has enough values to compute the avarage according to the max numbers it
may store (returns
IMovingAverage.getCurrentLength() == IMovingAverage.getMaxLength(). |
void |
reset()
Resets the object -> it removes all items stored.
|
void |
setMaxLength(int length)
Sets number of items that the object requires for the computing of the average.
|
public MovingAverage(IAveragator<TYPE> averagator)
public void add(TYPE item)
IMovingAverageadd in interface IMovingAverage<TYPE>public TYPE getAverage()
IMovingAverageReturns null if no values are stored.
getAverage in interface IMovingAverage<TYPE>public int getCurrentLength()
IMovingAverageIMovingAverage.getAverage().getCurrentLength in interface IMovingAverage<TYPE>public int getMaxLength()
IMovingAverageIMovingAverage.add(Object) that are used to
compute the average returned via IMovingAverage.getAverage().getMaxLength in interface IMovingAverage<TYPE>public boolean isEnoughValues()
IMovingAverageIMovingAverage.getCurrentLength() == IMovingAverage.getMaxLength().isEnoughValues in interface IMovingAverage<TYPE>public void reset()
IMovingAverageIMovingAverage.getAverage() will return
null after the call.reset in interface IMovingAverage<TYPE>public void setMaxLength(int length)
IMovingAverageIMovingAverage.isEnoughValues() reports true.)setMaxLength in interface IMovingAverage<TYPE>Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.