summaryrefslogtreecommitdiffstats
path: root/base/stl_util-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/stl_util-inl.h')
-rw-r--r--base/stl_util-inl.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/base/stl_util-inl.h b/base/stl_util-inl.h
index 54b7b29..70fa69e 100644
--- a/base/stl_util-inl.h
+++ b/base/stl_util-inl.h
@@ -447,4 +447,11 @@ std::vector<T> SetToVector(const std::set<T>& values) {
return result;
}
+// Test to see if a set, map, hash_set or hash_map contains a particular key.
+// Returns true if the key is in the collection.
+template <typename Collection, typename Key>
+bool ContainsKey(const Collection& collection, const Key& key) {
+ return collection.find(key) != collection.end();
+}
+
#endif // BASE_STL_UTIL_INL_H_