new time-grouping for vap grouper adjusted test-cases minor changes/fixes/improvements
44 lines
702 B
C++
44 lines
702 B
C++
#ifndef STATS_MAXIMUM_H
|
|
#define STATS_MAXIMUM_H
|
|
|
|
#include "../../Assertions.h"
|
|
#include <limits>
|
|
|
|
namespace Stats {
|
|
|
|
template <typename Scalar> class Maximum {
|
|
|
|
private:
|
|
|
|
const Scalar START = std::numeric_limits<Scalar>::lowest();
|
|
Scalar curMax;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
Maximum() : curMax(START) {
|
|
;
|
|
}
|
|
|
|
/** is a valid maximum available? */
|
|
inline bool isValid() const {
|
|
return curMax != START;
|
|
}
|
|
|
|
/** add a new value */
|
|
inline void add(const Scalar val) {
|
|
if (val > curMax) {curMax = val;}
|
|
}
|
|
|
|
/** get the current value */
|
|
inline Scalar get() const {
|
|
Assert::notEqual(curMax, START, "add() values first!");
|
|
return curMax;
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // STATS_MAXIMUM_H
|