|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
-
-
-
- #ifndef mn_histogram_included
- #define mn_histogram_included
-
- #include <set>
-
-
-
- namespace CodeDweller {
-
- class HistogramRecord {
- public:
- int Key;
- int Count;
- HistogramRecord(const int NewKey) :
- Key(NewKey), Count(0) {}
-
- bool operator<(const HistogramRecord& Right) const {
- return (Key < Right.Key);
- }
- };
-
- class Histogram : public std::set<HistogramRecord> {
- private:
- int HitCount;
- public:
- Histogram() : HitCount(0) {}
-
- int hit(const int EventKey, const int Adjustment = 1) {
- HistogramRecord E(EventKey);
- insert(E);
- std::set<HistogramRecord>::iterator iE =
- find(E);
- int* C;
- C = const_cast<int*>(&((*iE).Count));
- (*C) += Adjustment;
- HitCount += Adjustment;
- return(*C);
- }
-
- int Hits() { return HitCount; }
-
- void reset() {
- HitCount = 0;
- clear();
- }
- };
-
- }
-
- #endif
-
|