SLProject 4.0.000
Utils::Averaged< T > Class Template Reference

Averaged template class provides an average value from a fixed size array. More...

#include <Averaged.h>

Public Member Functions

 Averaged ()
 
 Averaged (int numValues, T initValue=0)
 
void init (int numValues, T initValue)
 Initializes the average value array to a given value. More...
 
void set (T value)
 Sets the current value in the value array and builds the average. More...
 
average ()
 
size_t size ()
 

Private Attributes

float _oneOverNumValues {}
 multiplier instead of divider More...
 
vector< T > _values
 value array More...
 
int _currentValueIndex {}
 current value index within _values More...
 
_sum
 sum of all values More...
 
_average
 average value More...
 

Detailed Description

template<class T>
class Utils::Averaged< T >

Averaged template class provides an average value from a fixed size array.

The Average template class provides a simple moving average value continuously averaged from a fixed size vector. The template class can be used for any template type T that provides the following operators: =, -, +, T* float

Constructor & Destructor Documentation

◆ Averaged() [1/2]

template<class T >
Utils::Averaged< T >::Averaged ( )
inline

◆ Averaged() [2/2]

template<class T >
Utils::Averaged< T >::Averaged ( int  numValues,
initValue = 0 
)
inline

Member Function Documentation

◆ average()

template<class T >
T Utils::Averaged< T >::average ( )
inline

◆ init()

template<class T >
void Utils::Averaged< T >::init ( int  numValues,
initValue 
)
inline

Initializes the average value array to a given value.

◆ set()

template<class T >
void Utils::Averaged< T >::set ( value)
inline

Sets the current value in the value array and builds the average.

◆ size()

template<class T >
size_t Utils::Averaged< T >::size ( )
inline

Member Data Documentation

◆ _average

template<class T >
T Utils::Averaged< T >::_average
private

average value

◆ _currentValueIndex

template<class T >
int Utils::Averaged< T >::_currentValueIndex {}
private

current value index within _values

◆ _oneOverNumValues

template<class T >
float Utils::Averaged< T >::_oneOverNumValues {}
private

multiplier instead of divider

◆ _sum

template<class T >
T Utils::Averaged< T >::_sum
private

sum of all values

◆ _values

template<class T >
vector<T> Utils::Averaged< T >::_values
private

value array


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