diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-10-19 17:34:17 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-10-19 18:31:49 +0300 |
commit | 1405a6189c56560366c5ce39bb7bec522e7439ab (patch) | |
tree | e2e03c83590187ab11ae23575bc9861a52a4a98b | |
parent | b9fe236a503791a3a7b37d4ef5f466225218996c (diff) | |
download | ydb-1405a6189c56560366c5ce39bb7bec522e7439ab.tar.gz |
Intermediate changes
-rw-r--r-- | yt/yt/core/misc/moving_average-inl.h | 9 | ||||
-rw-r--r-- | yt/yt/core/misc/moving_average.h | 3 |
2 files changed, 5 insertions, 7 deletions
diff --git a/yt/yt/core/misc/moving_average-inl.h b/yt/yt/core/misc/moving_average-inl.h index 2dcbd98185..acb53f7efa 100644 --- a/yt/yt/core/misc/moving_average-inl.h +++ b/yt/yt/core/misc/moving_average-inl.h @@ -18,7 +18,7 @@ template <class TValue> void TMovingAverage<TValue>::AddValue(TValue value) { Total_ += value; - Values_.push(std::move(value)); + Values_.push_back(std::move(value)); RemoveOldValues(); } @@ -46,10 +46,7 @@ void TMovingAverage<TValue>::SetWindowSize(int windowSize) template <class TValue> void TMovingAverage<TValue>::Reset() { - while (!Values_.empty()) { - Values_.pop(); - } - + Values_.clear(); Total_ = {}; } @@ -58,7 +55,7 @@ void TMovingAverage<TValue>::RemoveOldValues() { while (std::ssize(Values_) > WindowSize_) { Total_ -= Values_.front(); - Values_.pop(); + Values_.pop_front(); } } diff --git a/yt/yt/core/misc/moving_average.h b/yt/yt/core/misc/moving_average.h index f32e34a153..55257234ee 100644 --- a/yt/yt/core/misc/moving_average.h +++ b/yt/yt/core/misc/moving_average.h @@ -1,6 +1,7 @@ #pragma once #include "public.h" +#include "phoenix.h" namespace NYT { @@ -23,7 +24,7 @@ public: private: int WindowSize_ = 0; - std::queue<TValue> Values_; + std::deque<TValue> Values_; TValue Total_{}; void RemoveOldValues(); |