Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
AbstractHistogramIterator.java 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;
 
 import static org.HdrHistogram.AbstractHistogram.valueFromIndex;
 
Used for iterating through histogram values.
 
 
     int currentBucketIndex;
     int currentSubBucketIndex;
     long currentValueAtIndex;
 
     int nextBucketIndex;
     int nextSubBucketIndex;
     long nextValueAtIndex;
 
     long prevValueIteratedTo;
     long totalCountToPrevIndex;
 
 
     long arrayTotalCount;
     long countAtThisValue;
 
     private boolean freshSubBucket;
 
     void resetIterator(final AbstractHistogram histogram) {
         this. = histogram;
         this. = histogram.getTotalCount();
         this. = histogram.getTotalCount();
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 1;
         this. = 1;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = 0;
         this. = true;
         if (this. == null)
             this. = new HistogramIterationValue();
         .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.
 
     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.
 
     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 percentile reporting 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.
    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 next next index:
        ++;
        if ( >= .) {
            ++;
        }
    }
New to GrepCode? Check out our FAQ X