AK: Add min and max functions to Statistics

This commit is contained in:
Musab Kılıç 2021-10-29 15:59:52 +03:00 committed by Brian Gianforcaro
parent 5c75216361
commit f6a43c7cf5
Notes: sideshowbarker 2024-07-18 01:27:04 +09:00

View file

@ -29,6 +29,28 @@ public:
T const sum() const { return m_sum; }
float average() const { return (float)sum() / size(); }
T const min() const
{
T minimum = m_values[0];
for (T number : values()) {
if (number < minimum) {
minimum = number;
}
}
return minimum;
}
T const max() const
{
T maximum = m_values[0];
for (T number : values()) {
if (number > maximum) {
maximum = number;
}
}
return maximum;
}
// FIXME: Implement a better algorithm
T const median()
{