summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2012-09-10 10:41:19 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-09-17 10:13:32 -0400
commit3b738b913f169d816cc8ea7bdf6c4c3b51812ea7 (patch)
tree3c7f5b39367a7383a0fa83a9d420c6dc7044df80
parent12d1566416ced349c7b584b4c0590c5c3fe2228a (diff)
downloadmongo-3b738b913f169d816cc8ea7bdf6c4c3b51812ea7.tar.gz
Generalize mongo/util/map_util.h utilities to work with unordered maps, too.
-rw-r--r--src/mongo/util/map_util.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mongo/util/map_util.h b/src/mongo/util/map_util.h
index 8d401df6219..33579f4ede1 100644
--- a/src/mongo/util/map_util.h
+++ b/src/mongo/util/map_util.h
@@ -17,16 +17,14 @@
#pragma once
-#include <map>
-
namespace mongo {
/*
* If "myMap" contains "key", returns "myMap[key]". Otherwise, returns "defaultValue."
*/
-template <typename K, typename V>
-V mapFindWithDefault(const map<K,V>& myMap, const K& key, const V& defaultValue) {
- typename std::map<K,V>::const_iterator it = myMap.find(key);
+template <typename M, typename K, typename V>
+V mapFindWithDefault(const M& myMap, const K& key, const V& defaultValue) {
+ typename M::const_iterator it = myMap.find(key);
if(it == myMap.end())
return defaultValue;
return it->second;