Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <utility>
- #include <algorithm>
- class StaticMap {
- public:
- std::vector<std::pair<std::string, std::string>> all_items;
- explicit StaticMap(const std::vector<std::pair<std::string, std::string>>& items) {
- all_items = items;
- sort(all_items.begin(), all_items.end());
- }
- bool Find(const std::string& key, std::string* value) const {
- auto it = std::lower_bound(all_items.begin(), all_items.end(), key);
- if (it != all_items.end()){
- *value = (*it).second;
- return true;
- }
- return false;
- }
- };
Add Comment
Please, Sign In to add comment