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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void clear() { STLDeleteElements(&v_); } | 99 void clear() { STLDeleteElements(&v_); } |
100 | 100 |
101 // Like |clear()|, but doesn't delete any elements. | 101 // Like |clear()|, but doesn't delete any elements. |
102 void weak_clear() { v_.clear(); } | 102 void weak_clear() { v_.clear(); } |
103 | 103 |
104 // Lets the ScopedVector take ownership of |x|. | 104 // Lets the ScopedVector take ownership of |x|. |
105 iterator insert(iterator position, T* x) { | 105 iterator insert(iterator position, T* x) { |
106 return v_.insert(position, x); | 106 return v_.insert(position, x); |
107 } | 107 } |
108 | 108 |
| 109 iterator insert(iterator position, scoped_ptr<T> x) { |
| 110 return v_.insert(position, x.release()); |
| 111 } |
| 112 |
109 // Lets the ScopedVector take ownership of elements in [first,last). | 113 // Lets the ScopedVector take ownership of elements in [first,last). |
110 template<typename InputIterator> | 114 template<typename InputIterator> |
111 void insert(iterator position, InputIterator first, InputIterator last) { | 115 void insert(iterator position, InputIterator first, InputIterator last) { |
112 v_.insert(position, first, last); | 116 v_.insert(position, first, last); |
113 } | 117 } |
114 | 118 |
115 iterator erase(iterator position) { | 119 iterator erase(iterator position) { |
116 delete *position; | 120 delete *position; |
117 return v_.erase(position); | 121 return v_.erase(position); |
118 } | 122 } |
(...skipping 11 matching lines...) Expand all Loading... |
130 // Like |erase()|, but doesn't delete the elements in [first, last). | 134 // Like |erase()|, but doesn't delete the elements in [first, last). |
131 iterator weak_erase(iterator first, iterator last) { | 135 iterator weak_erase(iterator first, iterator last) { |
132 return v_.erase(first, last); | 136 return v_.erase(first, last); |
133 } | 137 } |
134 | 138 |
135 private: | 139 private: |
136 std::vector<T*> v_; | 140 std::vector<T*> v_; |
137 }; | 141 }; |
138 | 142 |
139 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ | 143 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ |
OLD | NEW |