code: public void add(int value) {
          int newIndex = (this.lastIndex + 1) % this.samples.length;
          if (this.count >= this.samples.length) {
              // We are going to overwrite a value, so subtract it from the grand sum.
              this.sum -= this.samples[newIndex];
          } else {
              this.count++;
          }
  
          // Record the new value and update stats.
          this.samples[newIndex] = value;
          this.sum += value;
          this.lastIndex = newIndex;
      }
docs: Adds the given value to the moving average. If the moving average is already at capacity, this will overwrite
  the oldest value in the series.
  
  @param value The value to add.