aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/hashmap.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/common/hashmap.h b/common/hashmap.h
index c859239606..b13ca79980 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -166,6 +166,7 @@ public:
Val &operator [](const Key &key);
const Val &operator [](const Key &key) const;
+ Val &getVal(const Key &key);
const Val &getVal(const Key &key) const;
void setVal(const Key &key, const Val &val);
@@ -381,9 +382,7 @@ bool HashMap<Key, Val, HashFunc, EqualFunc>::contains(const Key &key) const {
template <class Key, class Val, class HashFunc, class EqualFunc>
Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator [](const Key &key) {
- uint ctr = lookupAndCreateIfMissing(key);
- assert(_arr[ctr] != NULL);
- return _arr[ctr]->_value;
+ return getVal(key);
}
template <class Key, class Val, class HashFunc, class EqualFunc>
@@ -392,6 +391,13 @@ const Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator [](const Key &key) c
}
template <class Key, class Val, class HashFunc, class EqualFunc>
+Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) {
+ uint ctr = lookupAndCreateIfMissing(key);
+ assert(_arr[ctr] != NULL);
+ return _arr[ctr]->_value;
+}
+
+template <class Key, class Val, class HashFunc, class EqualFunc>
const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) const {
uint ctr = lookup(key);
assert(_arr[ctr] != NULL);