1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
6 #define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
7
8 namespace pdfium {
9
10 // Test to see if a set, map, hash_set or hash_map contains a particular key.
11 // Returns true if the key is in the collection.
12 template <typename Collection, typename Key>
ContainsKey(const Collection & collection,const Key & key)13 bool ContainsKey(const Collection& collection, const Key& key) {
14 return collection.find(key) != collection.end();
15 }
16
17 // Test to see if a collection like a vector contains a particular value.
18 // Returns true if the value is in the collection.
19 template <typename Collection, typename Value>
ContainsValue(const Collection & collection,const Value & value)20 bool ContainsValue(const Collection& collection, const Value& value) {
21 return std::find(collection.begin(), collection.end(), value) !=
22 collection.end();
23 }
24
25 } // namespace pdfium
26
27 #endif // PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
28