Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: third_party/base/stl_util.h

Issue 1618273004: Remove CFX_SegmentedArray use from master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_ 5 #ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
6 #define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_ 6 #define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
7 7
8 #include "third_party/base/numerics/safe_conversions.h"
9
8 namespace pdfium { 10 namespace pdfium {
9 11
10 // Test to see if a set, map, hash_set or hash_map contains a particular key. 12 // 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. 13 // Returns true if the key is in the collection.
12 template <typename Collection, typename Key> 14 template <typename Collection, typename Key>
13 bool ContainsKey(const Collection& collection, const Key& key) { 15 bool ContainsKey(const Collection& collection, const Key& key) {
14 return collection.find(key) != collection.end(); 16 return collection.find(key) != collection.end();
15 } 17 }
16 18
17 // Test to see if a collection like a vector contains a particular value. 19 // Test to see if a collection like a vector contains a particular value.
18 // Returns true if the value is in the collection. 20 // Returns true if the value is in the collection.
19 template <typename Collection, typename Value> 21 template <typename Collection, typename Value>
20 bool ContainsValue(const Collection& collection, const Value& value) { 22 bool ContainsValue(const Collection& collection, const Value& value) {
21 return std::find(collection.begin(), collection.end(), value) != 23 return std::find(collection.begin(), collection.end(), value) !=
22 collection.end(); 24 collection.end();
23 } 25 }
24 26
27 // Convenience routine for "int-fected" code, so that the stl collection
28 // size_t size() method return values will be checked.
29 template <typename ResultType, typename Collection>
30 ResultType CollectionSize(const Collection& collection) {
31 return pdfium::base::checked_cast<ResultType, size_t>(collection.size());
32 }
33
25 } // namespace pdfium 34 } // namespace pdfium
26 35
27 #endif // PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_ 36 #endif // PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698