53 lines
990 B
C++
53 lines
990 B
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#ifndef STATS_MINIMUM_H
|
||
#define STATS_MINIMUM_H
|
||
|
||
#include <limits>
|
||
|
||
namespace Stats {
|
||
|
||
template <typename Scalar> class Minimum {
|
||
|
||
private:
|
||
|
||
const Scalar START = std::numeric_limits<Scalar>::max();
|
||
Scalar curMin;
|
||
|
||
public:
|
||
|
||
/** ctor */
|
||
Minimum() : curMin(START) {
|
||
;
|
||
}
|
||
|
||
/** is a valid minimum available? */
|
||
inline bool isValid() const {
|
||
return curMin != START;
|
||
}
|
||
|
||
/** add a new value */
|
||
void add(const Scalar val) {
|
||
if (val < curMin) {curMin = val;}
|
||
}
|
||
|
||
/** get the current value */
|
||
Scalar get() const {
|
||
Assert::notEqual(curMin, START, "add() values first!");
|
||
return curMin;
|
||
}
|
||
|
||
};
|
||
|
||
}
|
||
|
||
#endif // STATS_MINIMUM_H
|