Used to insert a new mapping or overwrite an existing mapping. Note that if the value type of this container is a pointer, any overwritten pointer will be lost and if this container was the owner, you have a leak. Returns iterator pointing to the new or overwritten entry.
| 120 | // of this container is a pointer, any overwritten pointer will be lost and if this container |
| 121 | // was the owner, you have a leak. Returns iterator pointing to the new or overwritten entry. |
| 122 | iterator Overwrite(const K& k, const V& v) { |
| 123 | std::pair<iterator, bool> result = map_.insert(std::make_pair(k, v)); |
| 124 | if (!result.second) { |
| 125 | // Already there - update the value for the existing key |
| 126 | result.first->second = v; |
| 127 | } |
| 128 | return result.first; |
| 129 | } |
| 130 | |
| 131 | template <typename CreateFn> |
| 132 | V GetOrCreate(const K& k, CreateFn create) { |