MXS-1777 Cosmetic changes based on code reviews.

This commit is contained in:
Niclas Antti
2018-07-30 13:55:33 +03:00
parent 6351ab9c73
commit d52885d68d
3 changed files with 10 additions and 9 deletions

View File

@ -28,13 +28,14 @@ public:
int num_samples() const; int num_samples() const;
void reset(); void reset();
CumulativeAverage& operator+=(const CumulativeAverage& rhs); CumulativeAverage& operator+=(const CumulativeAverage& rhs);
CumulativeAverage operator+(const CumulativeAverage& rhs) const;
private: private:
double m_ave = 0; double m_ave = 0;
int m_num_samples = 0; int m_num_samples = 0;
int m_num_last_added = 0; int m_num_last_added = 0;
}; };
CumulativeAverage operator+(const CumulativeAverage& rhs, const CumulativeAverage& lhs);
/** Exponential Moving Average. */ /** Exponential Moving Average. */
class EMAverage class EMAverage
{ {

View File

@ -49,9 +49,9 @@ CumulativeAverage &CumulativeAverage::operator+=(const CumulativeAverage &rhs)
return *this; return *this;
} }
CumulativeAverage CumulativeAverage::operator+(const CumulativeAverage &rhs) const CumulativeAverage operator+(const CumulativeAverage& lhs, const CumulativeAverage& rhs)
{ {
return CumulativeAverage(*this) += rhs; return CumulativeAverage(lhs) += rhs;
} }
void CumulativeAverage::reset() void CumulativeAverage::reset()