CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/PatCandidates/interface/StringMap.h

Go to the documentation of this file.
00001 #ifndef DataFormats_PatCandidates_StringMap_h
00002 #define DataFormats_PatCandidates_StringMap_h
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <algorithm>   // for std::pair
00007 
00008 class StringMap {
00009     public:
00010         typedef std::pair<std::string, int32_t> value_type;
00011         typedef std::vector<value_type>         vector_type;
00012         typedef vector_type::const_iterator     const_iterator;
00013 
00014         void add(const std::string &string, int32_t value) ;
00015         void sort();
00016         void clear();
00017 
00021         int32_t operator[](const std::string &string) const ;
00022 
00026         const std::string & operator[](int32_t number) const ;
00027 
00028         const_iterator find(const std::string &string) const ;
00029         const_iterator find(int32_t number) const ;
00030 
00031         const_iterator begin() const { return entries_.begin(); }
00032         const_iterator end() const { return entries_.end(); }
00033     
00034         size_t size() const { return entries_.size(); }
00035     private:
00036         std::vector< std::pair<std::string, int32_t> > entries_;
00037         class MatchByString {
00038             public:
00039                 MatchByString() {}
00040                 //MatchByString(const std::string &string) : string_(string) {}
00041                 bool operator()(const value_type &val, const std::string &string) const { return  val.first < string; }
00042                 //bool operator()(const value_type &val) const { return string_ == val.first; }
00043             private:
00044                 //const std::string &string_;
00045         };
00046         class MatchByNumber {
00047             public:
00048                 MatchByNumber(int32_t number) : number_(number) {}
00049                 bool operator()(const value_type &val) const { return number_ == val.second; }
00050             private:
00051                 int32_t number_;
00052         };
00053         
00054 } ;
00055 
00056 #endif