statistic helper classes
test-cases modified grid importance for better trap-detection
This commit is contained in:
42
math/stats/Maximum.h
Normal file
42
math/stats/Maximum.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef STATS_MAXIMUM_H
|
||||
#define STATS_MAXIMUM_H
|
||||
|
||||
#include "../../Assertions.h"
|
||||
|
||||
namespace Stats {
|
||||
|
||||
template <typename Scalar> class Maximum {
|
||||
|
||||
private:
|
||||
|
||||
const Scalar START = -99999999;
|
||||
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
|
||||
Reference in New Issue
Block a user