PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
SimpleMovingAverage< Class T > Class Reference

Private Member Functions

void SimpleMovingAverage (int pSize, T pDefaultValue=0)
 Initialize Simple Moving Average Cyclic Buffer.
 
Add (T newSample)
 Add new value and return average value from buffer.
 
array< T > GetSamples ()
 Returns all the samples stored in the buffer.
 

Private Attributes

private T m_Sum = 0
 
private int m_Pointer = 0
 
private int m_Size = 0
 
private ref array< T > m_Samples = new array<T>()
 

Constructor & Destructor Documentation

◆ SimpleMovingAverage()

void SimpleMovingAverage ( int  pSize,
pDefaultValue = 0 
)
inlineprivate

Initialize Simple Moving Average Cyclic Buffer.

Parameters
pSizesize of the buffer
pDefaultValueinitial value stored in buffer

Member Function Documentation

◆ Add()

T Add ( newSample)
inlineprivate

Add new value and return average value from buffer.

Parameters
newSamplevalue that will be added to buffer
Returns
average value from the buffer
ref SimpleMovingAverage<float> m_Buffer = SimpleMovingAverage<float>(10, 0.5);
float sma = m_Buffer.Add(0.2);

◆ GetSamples()

array< T > GetSamples ( )
inlineprivate

Returns all the samples stored in the buffer.

Field Documentation

◆ m_Pointer

private int m_Pointer = 0
private

◆ m_Samples

private ref array<T> m_Samples = new array<T>()
private

◆ m_Size

private int m_Size = 0
private

◆ m_Sum

private T m_Sum = 0
private

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