From ff12f975b2b49dbf81125e1fa7081263b1dcc25f Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Thu, 18 May 2023 12:23:59 +0200 Subject: [PATCH] stats: allow cleaning the content of an histogram --- CHANGES.md | 1 + src/stats/model/histogram.cc | 6 ++++++ src/stats/model/histogram.h | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index cadfce005..0e40e76c3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ Changes from ns-3.38 to ns-3-dev * (network) Added `Mac16Address::Mac16Address(uint16t addr)` and `Mac16Address::Mac64Address(uint64t addr)` constructors. * (lr-wpan) Added `LrwpanMac::MlmeGetRequest` function and the corresponding confirm callbacks as well as `LrwpanMac::SetMlmeGetConfirm` function. * (applications) Added `Tx` and `TxWithAddresses` trace sources in `UdpClient`. +* (stats) Added `Histogram::Clear` function to clear the histogram contents. ### Changes to existing API diff --git a/src/stats/model/histogram.cc b/src/stats/model/histogram.cc index 96fa5d85e..2e58e4af9 100644 --- a/src/stats/model/histogram.cc +++ b/src/stats/model/histogram.cc @@ -92,6 +92,12 @@ Histogram::AddValue(double value) m_histogram[index]++; } +void +Histogram::Clear() +{ + m_histogram.clear(); +} + Histogram::Histogram(double binWidth) { m_binWidth = binWidth; diff --git a/src/stats/model/histogram.h b/src/stats/model/histogram.h index 9b378e428..7d5dedac9 100644 --- a/src/stats/model/histogram.h +++ b/src/stats/model/histogram.h @@ -102,6 +102,11 @@ class Histogram */ void AddValue(double value); + /** + * Clear the histogram content. + */ + void Clear(); + /** * \brief Serializes the results to an std::ostream in XML format. * \param os the output stream