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

Unified Diff: cc/scoped_ptr_algorithm.h

Issue 11418108: cc: Make the ScopedPtrVector and ScopedPtrDeque containers act like STL vector and deque. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android!! Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resource_provider_unittest.cc ('k') | cc/scoped_ptr_deque.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scoped_ptr_algorithm.h
diff --git a/cc/scoped_ptr_algorithm.h b/cc/scoped_ptr_algorithm.h
new file mode 100644
index 0000000000000000000000000000000000000000..2972b00b0717b82c5ea85b12fdaaf0a72ce4d18a
--- /dev/null
+++ b/cc/scoped_ptr_algorithm.h
@@ -0,0 +1,30 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_SCOPED_PTR_ALGORITHM_H_
+#define CC_SCOPED_PTR_ALGORITHM_H_
+
+namespace cc {
+
+// ScopedContainers need to implement a swap() method since they do not allow
+// assignment to their iterators.
+template <class ForwardIterator, class Predicate, class ScopedContainer>
+ForwardIterator remove_if(
+ ScopedContainer& container,
+ ForwardIterator first,
+ ForwardIterator last,
+ Predicate predicate) {
+ ForwardIterator result = first;
+ for (; first != last; ++first) {
+ if (!predicate(*first)) {
+ container.swap(first, result);
+ ++result;
+ }
+ }
+ return result;
+}
+
+} // namespace cc
+
+#endif // CC_SCOPED_PTR_ALGORITHM_H_
« no previous file with comments | « cc/resource_provider_unittest.cc ('k') | cc/scoped_ptr_deque.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698