9#include <userver/utils/assert.hpp>
10#include <userver/utils/fixed_array.hpp>
12USERVER_NAMESPACE_BEGIN
27class SlidingInterval final {
35 buckets_[idx_] = value;
37 if (idx_ == buckets_.size()) {
46 return std::accumulate(buckets_.begin(), buckets_.end(),
static_cast<T>(0)) /
this->buckets_.size();
52 [[nodiscard]] T
GetMinimal()
const {
return *std::min_element(buckets_.begin(), buckets_.end()); }
57 [[nodiscard]] T
GetMaximum()
const {
return *std::max_element(buckets_.begin(), buckets_.end()); }
61 [[nodiscard]] std::size_t
GetWindowSize()
const {
return buckets_.size(); }
64 utils::FixedArray<T> buckets_;