|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
-
-
-
-
- #ifndef mn_histogram_included
- #define mn_histogram_included
-
- #include <set>
-
- using namespace std;
-
-
-
- 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 set<HistogramRecord> {
- private:
- int HitCount;
- public:
- Histogram() : HitCount(0) {}
-
- int hit(const int EventKey, const int Adjustment = 1) {
- HistogramRecord E(EventKey);
- insert(E);
- 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
-
|