class RollingAverage {

    public double average() {
        if (position == 0) return 0; // no data yet
        double sum = 0;
        final int top = Math.min(position, size);
        // take average of populated entries
        for (int i = 0; i < top; i++) {
            sum += values[i];
        }
        return sum / top;
    }

    public  RollingAverage(final int size);

}