| 123 | } |
| 124 | |
| 125 | pair<bool, iterator> insert(const Key &key, const Value &value, |
| 126 | insert_result *result = nullptr) { |
| 127 | iterator it = find(key); |
| 128 | if (it != end()) { |
| 129 | if (result) { |
| 130 | *result = exists; |
| 131 | } |
| 132 | return {false, it}; |
| 133 | } |
| 134 | if (data.size() < N) { |
| 135 | data.push_back(PairKV(key, value)); |
| 136 | if (result) { |
| 137 | *result = inserted; |
| 138 | } |
| 139 | return {true, data.end() - 1}; |
| 140 | } |
| 141 | if (result) { |
| 142 | *result = at_capacity; |
| 143 | } |
| 144 | return {false, end()}; |
| 145 | } |
| 146 | |
| 147 | pair<bool, iterator> insert(Key &&key, Value &&value, |
| 148 | insert_result *result = nullptr) { |