@@ -74,6 +74,12 @@ Histogram::Histogram(Span<const uint32_t> data)
* \return Number of values
*/
+/**
+ * \fn Histogram::operator[](size_t bin) const
+ * \brief Retrieve the value for \a bin
+ * \return The value in \a bin, or 0 if \a bin is out of range
+ */
+
/**
* \brief Cumulative frequency up to a (fractional) point in a bin
* \param[in] bin The bin up to which to cumulate
@@ -42,6 +42,13 @@ public:
double quantile(double q, uint32_t first = 0, uint32_t last = UINT_MAX) const;
double interQuantileMean(double lowQuantile, double hiQuantile) const;
+ uint32_t operator[](size_t bin) const
+ {
+ return bin < bins()
+ ? cumulative_[bin + 1] - cumulative_[bin]
+ : 0;
+ }
+
private:
std::vector<uint64_t> cumulative_;
};
Add an `operator[]` that takes an integral bin number and returns the count pertaining to that specific bin. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/ipa/libipa/histogram.cpp | 6 ++++++ src/ipa/libipa/histogram.h | 7 +++++++ 2 files changed, 13 insertions(+)