private EventCount trimAndSum(long tickerNanos){
  final long oldLimit=tickerNanos - slidingWindowNanos;
  final Iterator<Bucket> iterator=reservoir.iterator();
  long success=0;
  long failure=0;
  while (iterator.hasNext()) {
    final Bucket bucket=iterator.next();
    if (bucket.timestamp < oldLimit) {
      iterator.remove();
    }
 else {
      success+=bucket.success();
      failure+=bucket.failure();
    }
  }
  return new EventCount(success,failure);
}

private EventCount trimAndSum ( long tickerNanos ) { final long oldLimit = tickerNanos - slidingWindowNanos ; final Iterator < Bucket > iterator = reservoir . iterator ( ) ; long success = 0 ; long failure = 0 ; while ( iterator . hasNext ( ) ) { final Bucket bucket = iterator . next ( ) ; if ( bucket . timestamp < oldLimit ) { iterator . remove ( ) ; } else { success += bucket . success ( ) ; failure += bucket . failure ( ) ; } } return new EventCount ( success , failure ) ; }
sums up buckets within the time window , and removes all the others .
