Files
BeatDetector/EndlessAVG.h
2017-07-15 15:52:05 +02:00

39 lines
548 B
C++
Executable File

#ifndef ENDLESSAVG_H
#define ENDLESSAVG_H
template <typename T> class EndlessAVG {
private:
/** track the current sum of the vector's values */
T curSum;
/** the number of elements to average */
int count;
public:
/** ctor */
EndlessAVG() : curSum(), count(0) {;}
/** add a new value */
void add(const T val) {
curSum += val;
++count;
}
/** get the current average */
T get() const {
return curSum / count;
}
/** get number of entries to average */
int getSize() const {
return count;
}
};
#endif // ENDLESSAVG_H