diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index e7ad807335..fc3a3f39d5 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -603,6 +603,7 @@ rtc_static_library("rtc_numerics") { ":checks", ":rtc_base_approved", ":safe_compare", + "../api:array_view", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/types:optional", ] diff --git a/rtc_base/numerics/samples_stats_counter.h b/rtc_base/numerics/samples_stats_counter.h index ac5f12cdea..43c58c7c32 100644 --- a/rtc_base/numerics/samples_stats_counter.h +++ b/rtc_base/numerics/samples_stats_counter.h @@ -13,6 +13,7 @@ #include +#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/running_statistics.h" @@ -75,6 +76,11 @@ class SamplesStatsCounter { // |percentile| has to be in [0; 1]. 0 percentile is the min in the array and // 1 percentile is the max in the array. double GetPercentile(double percentile); + // Returns array view with all samples added into counter. There are no + // guarantees of order, so samples can be in different order comparing to in + // which they were added into counter. Also return value will be invalidate + // after call to any non const method. + rtc::ArrayView GetSamples() const { return samples_; } private: RunningStatistics stats_;