Index: cc/scoped_ptr_vector.h |
diff --git a/cc/scoped_ptr_vector.h b/cc/scoped_ptr_vector.h |
index 28c00141004fede6e357428ac1b43796941938ff..6cbe812139508eacf1945154f6a489408763eb4e 100644 |
--- a/cc/scoped_ptr_vector.h |
+++ b/cc/scoped_ptr_vector.h |
@@ -31,53 +31,63 @@ class ScopedPtrVector { |
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> take(size_t index) { |
- DCHECK(index < size()); |
- scoped_ptr<T> ret(data_[index]); |
- data_[index] = NULL; |
+ scoped_ptr<T> take(iterator position) { |
enne (OOO)
2012/11/21 04:12:57
Same question here.
danakj
2012/11/21 04:23:21
But here, take is different than erase. It removes
|
+ if (position == end()) |
+ return scoped_ptr<T>(NULL); |
+ scoped_ptr<T> ret(*position); |
+ *position = NULL; |
return ret.Pass(); |
} |
- void remove(size_t index) { |
- DCHECK(index < size()); |
- delete data_[index]; |
- data_.erase(data_.begin() + index); |
+ void erase(iterator position) { |
+ if (position == end()) |
+ return; |
+ delete *position; |
+ data_.erase(position); |
+ } |
+ |
+ void erase(iterator first, iterator last) { |
+ DCHECK(first <= last); |
+ for (iterator it = first; it != last; ++it) { |
+ DCHECK(it != end()); |
+ delete *it; |
+ data_.erase(it); |
+ } |
} |
void clear() { |
STLDeleteElements(&data_); |
} |
- void append(scoped_ptr<T> item) { |
+ 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(); } |