OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_BASE_SCOPED_PTR_VECTOR_H_ | 5 #ifndef CC_BASE_SCOPED_PTR_VECTOR_H_ |
6 #define CC_BASE_SCOPED_PTR_VECTOR_H_ | 6 #define CC_BASE_SCOPED_PTR_VECTOR_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return data_.empty(); | 70 return data_.empty(); |
71 } | 71 } |
72 | 72 |
73 scoped_ptr<T> take(iterator position) { | 73 scoped_ptr<T> take(iterator position) { |
74 if (position == end()) | 74 if (position == end()) |
75 return nullptr; | 75 return nullptr; |
76 DCHECK(position < end()); | 76 DCHECK(position < end()); |
77 | 77 |
78 typename std::vector<T*>::iterator writable_position = position; | 78 typename std::vector<T*>::iterator writable_position = position; |
79 scoped_ptr<T> ret(*writable_position); | 79 scoped_ptr<T> ret(*writable_position); |
80 *writable_position = NULL; | 80 *writable_position = nullptr; |
81 return ret.Pass(); | 81 return ret.Pass(); |
82 } | 82 } |
83 | 83 |
84 scoped_ptr<T> take_back() { | 84 scoped_ptr<T> take_back() { |
85 DCHECK(!empty()); | 85 DCHECK(!empty()); |
86 if (empty()) | 86 if (empty()) |
87 return nullptr; | 87 return nullptr; |
88 return take(end() - 1); | 88 return take(end() - 1); |
89 } | 89 } |
90 | 90 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 private: | 192 private: |
193 std::vector<T*> data_; | 193 std::vector<T*> data_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); | 195 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); |
196 }; | 196 }; |
197 | 197 |
198 } // namespace cc | 198 } // namespace cc |
199 | 199 |
200 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ | 200 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ |
OLD | NEW |