summaryrefslogtreecommitdiff
path: root/runtime/safe_map.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/safe_map.h')
-rw-r--r--runtime/safe_map.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/safe_map.h b/runtime/safe_map.h
index 49f80f31a8..e638fdb504 100644
--- a/runtime/safe_map.h
+++ b/runtime/safe_map.h
@@ -137,6 +137,16 @@ class SafeMap {
return it->second;
}
+ iterator FindOrAdd(const K& k, const V& v) {
+ iterator it = find(k);
+ return it == end() ? Put(k, v) : it;
+ }
+
+ iterator FindOrAdd(const K& k) {
+ iterator it = find(k);
+ return it == end() ? Put(k, V()) : it;
+ }
+
bool Equals(const Self& rhs) const {
return map_ == rhs.map_;
}