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_SCOPED_PTR_VECTOR_H_ | 5 #ifndef CC_SCOPED_PTR_VECTOR_H_ |
6 #define CC_SCOPED_PTR_VECTOR_H_ | 6 #define CC_SCOPED_PTR_VECTOR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 data_[index] = NULL; | 60 data_[index] = NULL; |
61 return ret.Pass(); | 61 return ret.Pass(); |
62 } | 62 } |
63 | 63 |
64 void remove(size_t index) { | 64 void remove(size_t index) { |
65 DCHECK(index < size()); | 65 DCHECK(index < size()); |
66 delete data_[index]; | 66 delete data_[index]; |
67 data_.erase(data_.begin() + index); | 67 data_.erase(data_.begin() + index); |
68 } | 68 } |
69 | 69 |
| 70 void reserve(size_t size) { |
| 71 data_.reserve(size); |
| 72 } |
| 73 |
70 void clear() { | 74 void clear() { |
71 STLDeleteElements(&data_); | 75 STLDeleteElements(&data_); |
72 } | 76 } |
73 | 77 |
74 void append(scoped_ptr<T> item) { | 78 void append(scoped_ptr<T> item) { |
75 data_.push_back(item.release()); | 79 data_.push_back(item.release()); |
76 } | 80 } |
77 | 81 |
78 void insert(size_t index, scoped_ptr<T> item) { | 82 void insert(size_t index, scoped_ptr<T> item) { |
79 DCHECK(index < size()); | 83 DCHECK(index < size()); |
(...skipping 12 matching lines...) Expand all Loading... |
92 | 96 |
93 private: | 97 private: |
94 std::vector<T*> data_; | 98 std::vector<T*> data_; |
95 | 99 |
96 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); | 100 DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector); |
97 }; | 101 }; |
98 | 102 |
99 } // namespace cc | 103 } // namespace cc |
100 | 104 |
101 #endif // CC_SCOPED_PTR_VECTOR_H_ | 105 #endif // CC_SCOPED_PTR_VECTOR_H_ |
OLD | NEW |