Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
simplemovingaverage.c
Go to the documentation of this file.
1class SimpleMovingAverage<Class T>
2{
3 private T m_Sum = 0;
4 private int m_Pointer = 0;
5 private int m_Size = 0;
6 private ref array<T> m_Samples = new array<T>();
7
13 void SimpleMovingAverage(int pSize, T pDefaultValue = 0)
14 {
15 m_Size = pSize;
16
17 for (int i = 0; i < m_Size; i++)
18 {
19 m_Samples.Insert(pDefaultValue);
20 m_Sum += m_Samples[i];
21 }
22 }
23
33 T Add(T newSample)
34 {
35 m_Sum = m_Sum - m_Samples[m_Pointer] + newSample;
36 m_Samples[m_Pointer++] = newSample;
37 if (m_Pointer == m_Size)
38 {
39 m_Pointer = 0;
40 }
41
42 return m_Sum / m_Size;
43 }
44
48 array<T> GetSamples()
49 {
50 return m_Samples;
51 }
52}
Super root of all classes in Enforce script.
Definition enscript.c:11
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Add(string name, string value)