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 27 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 30 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 57 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 52 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 45 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 61 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 34 of file sliding_interval.hpp.


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