Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:25

0001 #include "DataFormats/PatCandidates/interface/StringMap.h"
0002 
0003 void StringMap::add(const std::string &string, int32_t value) { entries_.push_back(value_type(string, value)); }
0004 
0005 void StringMap::sort() { std::sort(entries_.begin(), entries_.end()); }
0006 
0007 void StringMap::clear() { entries_.clear(); }
0008 
0009 int32_t StringMap::operator[](const std::string &string) const {
0010   vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
0011   return (match == end() ? -1 : match->second);
0012 }
0013 
0014 const std::string &StringMap::operator[](int32_t number) const {
0015   static const std::string empty_;
0016   vector_type::const_iterator match = find(number);
0017   return (match == end() ? empty_ : match->first);
0018 }
0019 
0020 StringMap::const_iterator StringMap::find(const std::string &string) const {
0021   vector_type::const_iterator match = std::lower_bound(entries_.begin(), entries_.end(), string, MatchByString());
0022   return (match->first == string ? match : end());
0023 }
0024 
0025 StringMap::const_iterator StringMap::find(int32_t number) const {
0026   return std::find_if(entries_.begin(), entries_.end(), MatchByNumber(number));
0027 }