23 using pair_type = std::pair<Key, Value>;
24 using iterator =
typename std::vector<pair_type>::iterator;
25 using const_iterator =
typename std::vector<pair_type>::const_iterator;
27 void insert(
const Key& key,
const Value& value) {
28 auto it = std::lower_bound(
32 [](
const pair_type& lhs,
const Key& rhs) { return lhs.first < rhs; }
34 if (it != m_data.end() && it->first == key) {
39 m_data.insert(it, pair_type {key, value});
43 iterator find(
const Key& key) {
44 auto it = std::lower_bound(
48 [](
const pair_type& lhs,
const Key& rhs) { return lhs.first < rhs; }
50 if (it != m_data.end() && it->first == key) {
56 const_iterator find(
const Key& key)
const {
57 auto it = std::lower_bound(
61 [](
const pair_type& lhs,
const Key& rhs) { return lhs.first < rhs; }
63 if (it != m_data.end() && it->first == key) {
69 Value& operator[](
const Key& key) {
70 auto it = std::lower_bound(
74 [](
const pair_type& lhs,
const Key& rhs) { return lhs.first < rhs; }
76 if (it != m_data.end() && it->first == key) {
80 return m_data.insert(it, pair_type {key, Value {}})->second;
88 void erase(
const Key& key) {
89 auto it = std::lower_bound(
93 [](
const pair_type& lhs,
const Key& rhs) { return lhs.first < rhs; }
95 if (it != m_data.end() && it->first == key) {
100 iterator erase(iterator it) {
101 return m_data.erase(it);
104 size_t size()
const {
105 return m_data.size();
109 return m_data.empty();
113 return m_data.begin();
116 const_iterator begin()
const {
117 return m_data.begin();
124 const_iterator end()
const {
129 std::vector<pair_type>