public int next(int value) {
            if(fillLevel < values.length) {
                fillLevel++;
            }
            index = (index + 1) % values.length;
            int oldestIndex = positiveMod((index - values.length), values.length);
            averageSum -= values[oldestIndex];
            values[index] = value;
            averageSum += value;
            return average();
        }
Adds a new value and returns the new average.
MediaPlayer-DASH/src/main/java/net/protyposis/android/mediaplayer/dash/SimpleRateBasedAdaptationLogic.java