com.threerings.media.util
Class TrailingAverage

java.lang.Object
  extended by com.threerings.media.util.TrailingAverage

public class TrailingAverage
extends Object

Used to compute a trailing average of a value.


Field Summary
protected  int[] _history
          The history of values.
protected  int _index
          The index where we will next record a value.
 
Constructor Summary
TrailingAverage()
          Creates a trailing average instance with the default number of values used to compute the average (10).
TrailingAverage(int history)
          Creates a trailing average instance with the specified number of values used to compute the average.
 
Method Summary
 void record(int value)
          Records a new value.
 String toString()
           
 int value()
          Returns the current averaged value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_history

protected int[] _history
The history of values.


_index

protected int _index
The index where we will next record a value.

Constructor Detail

TrailingAverage

public TrailingAverage()
Creates a trailing average instance with the default number of values used to compute the average (10).


TrailingAverage

public TrailingAverage(int history)
Creates a trailing average instance with the specified number of values used to compute the average.

Method Detail

record

public void record(int value)
Records a new value.


value

public int value()
Returns the current averaged value.


toString

public String toString()
Overrides:
toString in class Object