return min_ + (idx * bucketSize_);
}
+ /**
+ * Computes the total number of values stored across all buckets.
+ *
+ * Runs in O(numBuckets)
+ *
+ * @param countFn A function that takes a const BucketType&, and returns the
+ * number of values in that bucket
+ * @return Returns the total number of values stored across all buckets
+ */
+ template <typename CountFn>
+ const uint64_t computeTotalCount(CountFn countFromBucket) const;
+
/**
* Determine which bucket the specified percentile falls into.
*
return buckets_.getBucketMax(idx);
}
+ /**
+ * Computes the total number of values stored across all buckets.
+ *
+ * Runs in O(numBuckets)
+ */
+ const uint64_t computeTotalCount() const {
+ CountFromBucket countFn;
+ return buckets_.computeTotalCount(countFn);
+ }
+
/*
* Get the bucket that the specified percentile falls into
*
*/
void toTSV(std::ostream& out, bool skipEmptyBuckets = true) const;
- private:
struct CountFromBucket {
uint64_t operator()(const Bucket& bucket) const {
return bucket.count;
}
};
+ private:
detail::HistogramBuckets<ValueType, Bucket> buckets_;
};