userver: utils::SlidingInterval< T > Class Template Reference
Loading...
Searching...
No Matches
utils::SlidingInterval< T > Class Template Referencefinal

#include <userver/utils/sliding_interval.hpp>

Detailed Description

template<typename T>
class utils::SlidingInterval< T >

Sliding interval of values that provides functions to compute average, min and max values from the last window_size values of interval.

It fits for small window_size values because has O(window_size) complexity on most operations.

See also
utils::statistics::MinMaxAvg for a concurrent safe computation over a whole measurement interval.

Definition at line 26 of file sliding_interval.hpp.

Public Member Functions

 SlidingInterval (std::size_t window_size)
 Create a SlidingInterval of window_size values.
 
void Update (T value)
 replaces the oldest value in interval with value, i.e slides the interval.
 
GetSmoothed () const
 
GetMinimal () const
 
GetMaximum () const
 
std::size_t GetWindowSize () const
 

Constructor & Destructor Documentation

◆ SlidingInterval()

template<typename T >
utils::SlidingInterval< T >::SlidingInterval ( std::size_t window_size)
inlineexplicit

Create a SlidingInterval of window_size values.

Definition at line 29 of file sliding_interval.hpp.

Member Function Documentation

◆ GetMaximum()

template<typename T >
T utils::SlidingInterval< T >::GetMaximum ( ) const
inline
Returns
Maximum value in the interval

Complexity: O(window_size)

Definition at line 62 of file sliding_interval.hpp.

◆ GetMinimal()

template<typename T >
T utils::SlidingInterval< T >::GetMinimal ( ) const
inline
Returns
Minimal value in the interval

Complexity: O(window_size)

Definition at line 55 of file sliding_interval.hpp.

◆ GetSmoothed()

template<typename T >
T utils::SlidingInterval< T >::GetSmoothed ( ) const
inline
Returns
Average value in the interval

Complexity: O(window_size)

Definition at line 46 of file sliding_interval.hpp.

◆ GetWindowSize()

template<typename T >
std::size_t utils::SlidingInterval< T >::GetWindowSize ( ) const
inline
Returns
Elements count in the interval, i.e. window_size passed to constructor.

Definition at line 68 of file sliding_interval.hpp.

◆ Update()

template<typename T >
void utils::SlidingInterval< T >::Update ( T value)
inline

replaces the oldest value in interval with value, i.e slides the interval.

Definition at line 35 of file sliding_interval.hpp.


The documentation for this class was generated from the following file: