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

Side by Side Diff: base/stl_util.h

Issue 1304063014: cc: Plumbing for BeginFrameSource based on Surfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | cc/surfaces/surface.h » ('j') | cc/surfaces/surface.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Derived from google3/util/gtl/stl_util.h 5 // Derived from google3/util/gtl/stl_util.h
6 6
7 #ifndef BASE_STL_UTIL_H_ 7 #ifndef BASE_STL_UTIL_H_
8 #define BASE_STL_UTIL_H_ 8 #define BASE_STL_UTIL_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 // Test to see if a collection like a vector contains a particular value. 206 // Test to see if a collection like a vector contains a particular value.
207 // Returns true if the value is in the collection. 207 // Returns true if the value is in the collection.
208 template <typename Collection, typename Value> 208 template <typename Collection, typename Value>
209 bool ContainsValue(const Collection& collection, const Value& value) { 209 bool ContainsValue(const Collection& collection, const Value& value) {
210 return std::find(collection.begin(), collection.end(), value) != 210 return std::find(collection.begin(), collection.end(), value) !=
211 collection.end(); 211 collection.end();
212 } 212 }
213 213
214 template <typename Collection, typename Value>
215 bool RemoveValue(Collection& collection, const Value& value) {
216 collection.erase(std::remove(collection.begin(), collection.end(), value), col lection.end());
217 }
218
214 namespace base { 219 namespace base {
215 220
216 // Returns true if the container is sorted. 221 // Returns true if the container is sorted.
217 template <typename Container> 222 template <typename Container>
218 bool STLIsSorted(const Container& cont) { 223 bool STLIsSorted(const Container& cont) {
219 // Note: Use reverse iterator on container to ensure we only require 224 // Note: Use reverse iterator on container to ensure we only require
220 // value_type to implement operator<. 225 // value_type to implement operator<.
221 return std::adjacent_find(cont.rbegin(), cont.rend(), 226 return std::adjacent_find(cont.rbegin(), cont.rend(),
222 std::less<typename Container::value_type>()) 227 std::less<typename Container::value_type>())
223 == cont.rend(); 228 == cont.rend();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 bool STLIncludes(const Arg1& a1, const Arg2& a2) { 271 bool STLIncludes(const Arg1& a1, const Arg2& a2) {
267 DCHECK(STLIsSorted(a1)); 272 DCHECK(STLIsSorted(a1));
268 DCHECK(STLIsSorted(a2)); 273 DCHECK(STLIsSorted(a2));
269 return std::includes(a1.begin(), a1.end(), 274 return std::includes(a1.begin(), a1.end(),
270 a2.begin(), a2.end()); 275 a2.begin(), a2.end());
271 } 276 }
272 277
273 } // namespace base 278 } // namespace base
274 279
275 #endif // BASE_STL_UTIL_H_ 280 #endif // BASE_STL_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface.h » ('j') | cc/surfaces/surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698