1 class SimpleMovingAverage<
Class T>
4 private int m_Pointer = 0;
5 private int m_Size = 0;
13 void SimpleMovingAverage(
int pSize, T pDefaultValue = 0)
17 for (
int i = 0; i < m_Size; i++)
19 m_Samples.Insert(pDefaultValue);
20 m_Sum += m_Samples[i];
35 m_Sum = m_Sum - m_Samples[m_Pointer] + newSample;
36 m_Samples[m_Pointer++] = newSample;
37 if (m_Pointer == m_Size)
42 return m_Sum / m_Size;