CMS 3D CMS Logo

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