CMS 3D CMS Logo

StringMap.cc
Go to the documentation of this file.
2 
3 void StringMap::add(const std::string &string, int32_t value) {
4  entries_.push_back(value_type(string,value));
5 }
6 
8  std::sort(entries_.begin(), entries_.end());
9 }
10 
12  entries_.clear();
13 }
14 
15 int32_t StringMap::operator[](const std::string &string) const {
16  vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
17  return (match == end() ? -1 : match->second);
18 }
19 
20 const std::string & StringMap::operator[](int32_t number) const {
21  static const std::string empty_;
22  vector_type::const_iterator match = find(number);
23  return (match == end() ? empty_ : match->first);
24 }
25 
27  vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
28  return (match->first == string ? match : end());
29 }
30 
32  return std::find_if(entries_.begin(), entries_.end(), MatchByNumber(number));
33 }
34 
35 
void add(const std::string &string, int32_t value)
Definition: StringMap.cc:3
const_iterator end() const
Definition: StringMap.h:32
int32_t operator[](const std::string &string) const
Definition: StringMap.cc:15
void clear()
Definition: StringMap.cc:11
vector_type::const_iterator const_iterator
Definition: StringMap.h:12
std::vector< std::pair< std::string, int32_t > > entries_
Definition: StringMap.h:52
Definition: value.py:1
const_iterator find(const std::string &string) const
Definition: StringMap.cc:26
std::pair< std::string, int32_t > value_type
Definition: StringMap.h:10
void sort()
Definition: StringMap.cc:7
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10