| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 DCHECK(!empty()); | 65 DCHECK(!empty()); |
| 66 return at(size() - 1); | 66 return at(size() - 1); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool empty() const { | 69 bool empty() const { |
| 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 scoped_ptr<T>(NULL); | 75 return scoped_ptr<T>(); |
| 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 = NULL; |
| 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()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 std::vector<T*> data_; | 173 std::vector<T*> data_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); | 175 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace cc | 178 } // namespace cc |
| 179 | 179 |
| 180 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ | 180 #endif // CC_BASE_SCOPED_PTR_VECTOR_H_ |
| OLD | NEW |