| 100 | // value in the map is replaced with the value from the given pair. |
| 101 | template <class Collection> |
| 102 | bool InsertOrUpdate(Collection* const collection, |
| 103 | const typename Collection::value_type& vt) { |
| 104 | std::pair<typename Collection::iterator, bool> ret = collection->insert(vt); |
| 105 | if (!ret.second) { |
| 106 | // update |
| 107 | ret.first->second = vt.second; |
| 108 | return false; |
| 109 | } |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | // Same as above, except that the key and value are passed separately. |
| 114 | template <class Collection> |
no test coverage detected