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

Unified Diff: cc/scoped_ptr_deque.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: Add DCHECK Created 8 years, 1 month 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
Index: cc/scoped_ptr_deque.h
diff --git a/cc/scoped_ptr_deque.h b/cc/scoped_ptr_deque.h
index 64f09a8a8ec11f2a6f66ea5f9df41017ef21296d..338d4d62845dc84e6bcea6c3b8d52dae67cc620f 100644
--- a/cc/scoped_ptr_deque.h
+++ b/cc/scoped_ptr_deque.h
@@ -31,37 +31,37 @@ class ScopedPtrDeque {
return data_.size();
}
- T* Peek(size_t index) const {
+ T* at(size_t index) const {
DCHECK(index < size());
return data_[index];
}
T* operator[](size_t index) const {
- return Peek(index);
+ return at(index);
}
- T* first() const {
- DCHECK(!isEmpty());
- return Peek(0);
+ T* front() const {
+ DCHECK(!empty());
+ return at(0);
}
- T* last() const {
- DCHECK(!isEmpty());
- return Peek(size() - 1);
+ T* back() const {
+ DCHECK(!empty());
+ return at(size() - 1);
}
- bool isEmpty() const {
+ bool empty() const {
return size() == 0;
}
- scoped_ptr<T> takeFirst() {
- scoped_ptr<T> ret(first());
+ scoped_ptr<T> take_front() {
enne (OOO) 2012/11/21 04:12:57 I know take is convenient, but it's also inconsist
danakj 2012/11/21 04:23:21 Oh, take_front is removing the element so it could
+ scoped_ptr<T> ret(front());
data_.pop_front();
return ret.Pass();
}
- scoped_ptr<T> takeLast() {
- scoped_ptr<T> ret(last());
+ scoped_ptr<T> take_back() {
+ scoped_ptr<T> ret(back());
data_.pop_back();
return ret.Pass();
}
@@ -70,13 +70,16 @@ class ScopedPtrDeque {
STLDeleteElements(&data_);
}
- void append(scoped_ptr<T> item) {
+ void push_front(scoped_ptr<T> item) {
+ data_.push_front(item.release());
+ }
+
+ void push_back(scoped_ptr<T> item) {
data_.push_back(item.release());
}
- void insert(size_t index, scoped_ptr<T> item) {
- DCHECK(index < size());
- data_.insert(data_.begin() + index, item.release());
+ void insert(iterator position, scoped_ptr<T> item) {
+ data_.insert(position, item.release());
}
iterator begin() { return data_.begin(); }
« no previous file with comments | « cc/resource_provider_unittest.cc ('k') | cc/scoped_ptr_vector.h » ('j') | cc/scoped_ptr_vector.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698