diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 07:22:45 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 07:22:45 +0000 |
commit | ead39c5d73da35d0e0e4e9c1a02c53ec3727cb53 (patch) | |
tree | b42ce1909161c94b5e72eae7bd4a6ec878d5c6b7 /cc/scoped_ptr_algorithm.h | |
parent | 46ad823d93a1223e34ea3160284d45163ab7a2d0 (diff) | |
download | chromium_src-ead39c5d73da35d0e0e4e9c1a02c53ec3727cb53.zip chromium_src-ead39c5d73da35d0e0e4e9c1a02c53ec3727cb53.tar.gz chromium_src-ead39c5d73da35d0e0e4e9c1a02c53ec3727cb53.tar.bz2 |
cc: Make the ScopedPtrVector and ScopedPtrDeque containers act like STL vector and deque.
These classes used methods to match the webcore classes and ease
migration. Now they are at odds with the STL versions of these containers.
Rename the methods, and change arguments from indexes to iterators, to
match the STL containers.
isEmpty() => empty()
last() => back()
first() => front()
Peek() => at()
append() => push_back()
insert(index, value) => insert(iterator, value)
remove(index) => erase(iterator) and erase(iterator, iterator)
take(index) => take(iterator)
takeFront() => take_front()
takeBack() => take_back()
Review URL: https://chromiumcodereview.appspot.com/11418108
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scoped_ptr_algorithm.h')
-rw-r--r-- | cc/scoped_ptr_algorithm.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cc/scoped_ptr_algorithm.h b/cc/scoped_ptr_algorithm.h new file mode 100644 index 0000000..2972b00 --- /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_ |