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 in sorted order. The order may be ascending or descending.
  • 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 Type
    Method
    Description
    void
    Moves the iterator to the next, non-empty bucket.
    boolean
    Checks if there are any buckets remaining to be visited by this iterator.
    long
    The number of items in the bucket at the current iterator position.
    long
    The index of the bucket at the current iterator position.
    int
    Provides the scale that can be used to convert indices returned by peekIndex() to the bucket boundaries, e.g., via ExponentialScaleUtils.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 call peekCount(), peekIndex(), or advance().
      Returns:
      true if the iterator has more elements, false otherwise
    • peekCount

      long peekCount()
      The number of items in the bucket at the current iterator position. Does not advance the iterator. Must not be called if hasNext() returns false.
      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 if hasNext() returns false.
      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.
    • scale

      int scale()
      Provides the scale that can be used to convert indices returned by peekIndex() to the bucket boundaries, e.g., via ExponentialScaleUtils.getLowerBucketBoundary(long, int).
      Returns:
      the scale, which is guaranteed to be constant over the lifetime of this iterator