GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::SlidingWindow< T, N > Class Template Reference

Sliding window of a discrete-time input signal. More...

#include <GREM/core/statistics.hpp>

Classes

struct  Statistics
 Statistics of the sliding window. More...

Public Member Functions

void clear () noexcept
 Clear the sliding window of all samples.
void update (T newSample) noexcept
 Push a new sample into the sliding window, popping the oldest sample first if the window is at its maximum capacity.
Statistics getStatistics () const noexcept
 Calculate the statistics of the current samples in the sliding window.
auto getSamples () const noexcept
 Get the samples in the sliding window.

Detailed Description

template<typename T, std::size_t N>
class grem::SlidingWindow< T, N >

Sliding window of a discrete-time input signal.

Template Parameters
Tsignal value type. Must be a type that behaves like a number.
Nnumber of samples in the sliding window. Must be positive.

Member Function Documentation

◆ clear()

template<typename T, std::size_t N>
void grem::SlidingWindow< T, N >::clear ( )
inlinenoexcept

Clear the sliding window of all samples.

◆ update()

template<typename T, std::size_t N>
void grem::SlidingWindow< T, N >::update ( T newSample)
inlinenoexcept

Push a new sample into the sliding window, popping the oldest sample first if the window is at its maximum capacity.

Parameters
newSamplenew sample to add.

◆ getStatistics()

template<typename T, std::size_t N>
Statistics grem::SlidingWindow< T, N >::getStatistics ( ) const
inlinenodiscardnoexcept

Calculate the statistics of the current samples in the sliding window.

Returns
the current statistics of the sliding window.

◆ getSamples()

template<typename T, std::size_t N>
auto grem::SlidingWindow< T, N >::getSamples ( ) const
inlinenodiscardnoexcept

Get the samples in the sliding window.

Returns
a read-only view over the current samples in the sliding window, ordered from oldest to newest, valid until the next time the window is modified or destroyed.

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