| // Copyright (C) 2006 - 2009 MicroNeil Research Corporation | // Copyright (C) 2006 - 2009 MicroNeil Research Corporation | ||||
| // Class to capture a histogram of events using a <set> | // Class to capture a histogram of events using a <set> | ||||
| #ifndef mn_histogram_included | |||||
| #define mn_histogram_included | |||||
| #pragma once | |||||
| #include <set> | #include <set> | ||||
| using namespace std; | |||||
| namespace codedweller { | |||||
| /** The Histogram class is managed set of HistogramRecords. | /** The Histogram class is managed set of HistogramRecords. | ||||
| *** We play some naughty tricks with pointers to break the rules and | *** We play some naughty tricks with pointers to break the rules and | ||||
| class HistogramRecord { // A record to assocate a key and count. | class HistogramRecord { // A record to assocate a key and count. | ||||
| public: | public: | ||||
| int Key; // Here is the key. | int Key; // Here is the key. | ||||
| int Count; // Here is the count. | |||||
| mutable int Count; // Here is the count. | |||||
| HistogramRecord(const int NewKey) : // We must have a key to make one. | HistogramRecord(const int NewKey) : // We must have a key to make one. | ||||
| Key(NewKey), Count(0) {} // and a new one starts at count 0. | Key(NewKey), Count(0) {} // and a new one starts at count 0. | ||||
| } | } | ||||
| }; | }; | ||||
| class Histogram : public set<HistogramRecord> { // A Histogram is a set of HistogramRecords | |||||
| class Histogram : public std::set<HistogramRecord> { // A Histogram is a set of HistogramRecords | |||||
| private: // and a private hit counter... | private: // and a private hit counter... | ||||
| int HitCount; | int HitCount; | ||||
| public: | public: | ||||
| } | } | ||||
| }; | }; | ||||
| #endif | |||||
| } // End namespace codedweller | |||||