private void updateTransferredBytesAvg(int newValue){
  int realCount=0;
  int sum=0;
  this.avgSamples[this.nextSampleIndex++]=newValue;
  if (this.nextSampleIndex >= BYTES_TRANSFERRED_AVG_SAMPLES) {
    this.nextSampleIndex=0;
  }
  for (int i=0; i < BYTES_TRANSFERRED_AVG_SAMPLES; i++) {
    if (this.avgSamples[i] > 0) {
      realCount++;
      sum+=this.avgSamples[i];
    }
  }
  if (realCount > 0) {
    this.avgTransferredBytes=sum / realCount;
  }
 else {
    this.avgTransferredBytes=0;
  }
}

private void updateTransferredBytesAvg ( int newValue ) { int realCount = 0 ; int sum = 0 ; this . avgSamples [ this . nextSampleIndex ++ ] = newValue ; if ( this . nextSampleIndex >= BYTES_TRANSFERRED_AVG_SAMPLES ) { this . nextSampleIndex = 0 ; } for ( int i = 0 ; i < BYTES_TRANSFERRED_AVG_SAMPLES ; i ++ ) { if ( this . avgSamples [ i ] > 0 ) { realCount ++ ; sum += this . avgSamples [ i ] ; } } if ( realCount > 0 ) { this . avgTransferredBytes = sum / realCount ; } else { this . avgTransferredBytes = 0 ; } }
updates the average estimate of the number of bytes transferred per transfer opportunity .
