CMS 3D CMS Logo

StringMap.h
Go to the documentation of this file.
1 #ifndef DataFormats_PatCandidates_StringMap_h
2 #define DataFormats_PatCandidates_StringMap_h
3 
4 #include <string>
5 #include <vector>
6 #include <algorithm> // for std::pair
7 
8 class StringMap {
9 public:
10  typedef std::pair<std::string, int32_t> value_type;
11  typedef std::vector<value_type> vector_type;
12  typedef vector_type::const_iterator const_iterator;
13 
14  void add(const std::string &string, int32_t value);
15  void sort();
16  void clear();
17 
21  int32_t operator[](const std::string &string) const;
22 
26  const std::string &operator[](int32_t number) const;
27 
28  const_iterator find(const std::string &string) const;
29  const_iterator find(int32_t number) const;
30 
31  const_iterator begin() const { return entries_.begin(); }
32  const_iterator end() const { return entries_.end(); }
33 
34  size_t size() const { return entries_.size(); }
35  class MatchByString {
36  public:
38  //MatchByString(const std::string &string) : string_(string) {}
39  bool operator()(const value_type &val, const std::string &string) const { return val.first < string; }
40  //bool operator()(const value_type &val) const { return string_ == val.first; }
41  private:
42  //const std::string &string_;
43  };
44  class MatchByNumber {
45  public:
47  bool operator()(const value_type &val) const { return number_ == val.second; }
48 
49  private:
50  int32_t number_;
51  };
52 
53 private:
54  std::vector<std::pair<std::string, int32_t> > entries_;
55 };
56 
57 #endif
StringMap::MatchByNumber::operator()
bool operator()(const value_type &val) const
Definition: StringMap.h:47
StringMap::MatchByNumber::MatchByNumber
MatchByNumber(int32_t number)
Definition: StringMap.h:46
StringMap::size
size_t size() const
Definition: StringMap.h:34
StringMap::MatchByNumber
Definition: StringMap.h:44
StringMap::clear
void clear()
Definition: StringMap.cc:7
StringMap::vector_type
std::vector< value_type > vector_type
Definition: StringMap.h:11
StringMap::const_iterator
vector_type::const_iterator const_iterator
Definition: StringMap.h:12
StringMap::MatchByNumber::number_
int32_t number_
Definition: StringMap.h:50
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
StringMap
Definition: StringMap.h:8
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
StringMap::sort
void sort()
Definition: StringMap.cc:5
StringMap::MatchByString
Definition: StringMap.h:35
StringMap::end
const_iterator end() const
Definition: StringMap.h:32
value
Definition: value.py:1
StringMap::MatchByString::operator()
bool operator()(const value_type &val, const std::string &string) const
Definition: StringMap.h:39
StringMap::operator[]
int32_t operator[](const std::string &string) const
Definition: StringMap.cc:9
StringMap::entries_
std::vector< std::pair< std::string, int32_t > > entries_
Definition: StringMap.h:54
StringMap::find
const_iterator find(const std::string &string) const
Definition: StringMap.cc:20
StringMap::begin
const_iterator begin() const
Definition: StringMap.h:31
heppy_batch.val
val
Definition: heppy_batch.py:351
StringMap::MatchByString::MatchByString
MatchByString()
Definition: StringMap.h:37
StringMap::add
void add(const std::string &string, int32_t value)
Definition: StringMap.cc:3
StringMap::value_type
std::pair< std::string, int32_t > value_type
Definition: StringMap.h:10