Interface BucketIterator
- All Known Subinterfaces:
CopyableBucketIterator
public interface BucketIterator
An iterator over the non-empty buckets of the histogram for either the positive or negative range.
- The iterator always iterates from the lowest bucket index to the highest.
- The iterator never returns duplicate buckets (buckets with the same index).
- The iterator never returns empty buckets (
peekCount()is never zero).
-
Method Summary
Modifier and TypeMethodDescriptionvoidadvance()Moves the iterator to the next, non-empty bucket.booleanhasNext()Checks if there are any buckets remaining to be visited by this iterator.longThe number of items in the bucket at the current iterator position.longThe index of the bucket at the current iterator position.intscale()Provides the scale that can be used to convert indices returned bypeekIndex()to the bucket boundaries, e.g., viaExponentialScaleUtils.getLowerBucketBoundary(long, int).
-
Method Details
-
hasNext
boolean hasNext()Checks if there are any buckets remaining to be visited by this iterator. If the end has been reached, it is illegal to callpeekCount(),peekIndex(), oradvance().- Returns:
trueif the iterator has more elements,falseotherwise
-
peekCount
long peekCount()The number of items in the bucket at the current iterator position. Does not advance the iterator. Must not be called ifhasNext()returnsfalse.- Returns:
- the number of items in the bucket, always greater than zero
-
peekIndex
long peekIndex()The index of the bucket at the current iterator position. Does not advance the iterator. Must not be called ifhasNext()returnsfalse.- Returns:
- the index of the bucket, guaranteed to be in the range
[
ExponentialHistogram.MIN_INDEX,ExponentialHistogram.MAX_INDEX]
-
advance
void advance()Moves the iterator to the next, non-empty bucket. IfhasNext()istrueafter callingadvance(),peekIndex()is guaranteed to return a value greater than the value returned prior to theadvance()call. -
scale
int scale()Provides the scale that can be used to convert indices returned bypeekIndex()to the bucket boundaries, e.g., viaExponentialScaleUtils.getLowerBucketBoundary(long, int).- Returns:
- the scale, which is guaranteed to be constant over the lifetime of this iterator
-