1 #ifndef BST_ROLLING_AVERAGE_HPP_
2 #define BST_ROLLING_AVERAGE_HPP_
13 template <
typename T =
double>
Moving average calculator.
Definition: rolling_average.hpp:14
RollingAverage(size_t window_size)
Construct a RollingAverage object.
Definition: rolling_average.hpp:20
void removeOldest()
Remove the oldest element from the queue and update the sum. Safe to call if the queue is empty.
Definition: rolling_average.hpp:99
void clear()
Remove all elements from the queue and reset the sum to zero.
Definition: rolling_average.hpp:73
size_t window_size_
Definition: rolling_average.hpp:108
size_t getWindowSize() const
Get the window size.
Definition: rolling_average.hpp:91
T sum_
Definition: rolling_average.hpp:109
void addValue(T value)
Add a value to the rolling average. If the queue size exceeds the window size, the oldest value will ...
Definition: rolling_average.hpp:34
void setWindowSize(size_t new_window_size)
Set the window size. If the new window size is smaller than the current queue size,...
Definition: rolling_average.hpp:62
std::queue< T > queue_
Definition: rolling_average.hpp:107
T getAverage() const
This method returns the rolling average.
Definition: rolling_average.hpp:49
~RollingAverage()=default
Default destructor.
size_t getNumElements() const
Get the number of elements in the queue. This number may be less than the window size.
Definition: rolling_average.hpp:83
Definition: filesystem.cpp:34