Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ | 5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ |
| 6 #define BASE_MEMORY_SCOPED_VECTOR_H_ | 6 #define BASE_MEMORY_SCOPED_VECTOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 iterator end() { return v_.end(); } | 57 iterator end() { return v_.end(); } |
| 58 const_iterator end() const { return v_.end(); } | 58 const_iterator end() const { return v_.end(); } |
| 59 | 59 |
| 60 const_reference front() const { return v_.front(); } | 60 const_reference front() const { return v_.front(); } |
| 61 reference front() { return v_.front(); } | 61 reference front() { return v_.front(); } |
| 62 const_reference back() const { return v_.back(); } | 62 const_reference back() const { return v_.back(); } |
| 63 reference back() { return v_.back(); } | 63 reference back() { return v_.back(); } |
| 64 | 64 |
| 65 void push_back(T* elem) { v_.push_back(elem); } | 65 void push_back(T* elem) { v_.push_back(elem); } |
| 66 | 66 |
| 67 void pop_back() { | |
| 68 DCHECK(!empty()); | |
|
willchan no longer on Chromium
2013/11/28 17:44:19
Add logging.h for this.
Philippe
2013/11/29 12:41:05
Done.
| |
| 69 delete v_.back(); | |
| 70 v_.pop_back(); | |
| 71 } | |
| 72 | |
| 67 std::vector<T*>& get() { return v_; } | 73 std::vector<T*>& get() { return v_; } |
| 68 const std::vector<T*>& get() const { return v_; } | 74 const std::vector<T*>& get() const { return v_; } |
| 69 void swap(std::vector<T*>& other) { v_.swap(other); } | 75 void swap(std::vector<T*>& other) { v_.swap(other); } |
| 70 void swap(ScopedVector<T>& other) { v_.swap(other.v_); } | 76 void swap(ScopedVector<T>& other) { v_.swap(other.v_); } |
| 71 void release(std::vector<T*>* out) { | 77 void release(std::vector<T*>* out) { |
| 72 out->swap(v_); | 78 out->swap(v_); |
| 73 v_.clear(); | 79 v_.clear(); |
| 74 } | 80 } |
| 75 | 81 |
| 76 void reserve(size_t capacity) { v_.reserve(capacity); } | 82 void reserve(size_t capacity) { v_.reserve(capacity); } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 // Like |erase()|, but doesn't delete the elements in [first, last). | 127 // Like |erase()|, but doesn't delete the elements in [first, last). |
| 122 iterator weak_erase(iterator first, iterator last) { | 128 iterator weak_erase(iterator first, iterator last) { |
| 123 return v_.erase(first, last); | 129 return v_.erase(first, last); |
| 124 } | 130 } |
| 125 | 131 |
| 126 private: | 132 private: |
| 127 std::vector<T*> v_; | 133 std::vector<T*> v_; |
| 128 }; | 134 }; |
| 129 | 135 |
| 130 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ | 136 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ |
| OLD | NEW |