Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Written by Gil Tene of Azul Systems, and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/

Author(s):
Gil Tene
  
  
  package org.HdrHistogram;
  
Used for iterating through histogram values.
 
 
     int currentIndex;
     long currentValueAtIndex;
 
     long nextValueAtIndex;
 
     long prevValueIteratedTo;
     long totalCountToPrevIndex;
 
 
     long arrayTotalCount;
     long countAtThisValue;
 
     private boolean freshSubBucket;
 
     private double integerToDoubleValueConversionRatio;
 
     void resetIterator(final AbstractHistogram histogram) {
         this. = histogram;
         this. = histogram.getTotalCount();
         this. = histogram.getTotalCount();
         this. = 0;
         this. = 0;
         this. = 1 << histogram.unitMagnitude;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = true;
         .reset();
     }

    
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:
true if the iterator has more elements.
 
     @Override
     public boolean hasNext() {
         if (.getTotalCount() != ) {
             throw new ConcurrentModificationException();
         }
         return ( < );
     }

    
Returns the next element in the iteration.

Returns:
the HistogramIterationValue associated with the next element in the iteration.
 
     @Override
     public HistogramIterationValue next() {
         // Move through the sub buckets and buckets until we hit the next reporting level:
         while (!exhaustedSubBuckets()) {
             if () { // Don't add unless we've incremented since last bucket...
                  += ;
                  = false;
             }
             if (reachedIterationLevel()) {
                 long valueIteratedTo = getValueIteratedTo();
                 .set(valueIteratedTo,
                         ( - ), ,
                         , ((100.0 * ) / ),
                         getPercentileIteratedTo(), );
                  = valueIteratedTo;
                  = ;
                 // move the next iteration level forward:
                 incrementIterationLevel();
                 if (.getTotalCount() != ) {
                     throw new ConcurrentModificationException();
                 }
                 return ;
             }
            incrementSubBucket();
        }
        // Should not reach here. But possible for overflowed histograms under certain conditions
        throw new ArrayIndexOutOfBoundsException();
    }

    
Not supported. Will throw an java.lang.UnsupportedOperationException.
    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
    abstract void incrementIterationLevel();
    abstract boolean reachedIterationLevel();
    double getPercentileIteratedTo() {
        return (100.0 * (double) / ;
    }
    double getPercentileIteratedFrom() {
        return (100.0 * (double) / ;
    }
    long getValueIteratedTo() {
    }
    private boolean exhaustedSubBuckets() {
        return ( >= .);
    }
    void incrementSubBucket() {
         = true;
        // Take on the next index:
        ++;
        // Figure out the value at the next index (used by some iterators):
    }
New to GrepCode? Check out our FAQ X