Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_LIST_CONTAINER_H_ | 5 #ifndef CC_BASE_LIST_CONTAINER_H_ |
| 6 #define CC_BASE_LIST_CONTAINER_H_ | 6 #define CC_BASE_LIST_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 Iterator InsertBeforeAndInvalidateAllPointers(Iterator at, size_t count) { | 137 Iterator InsertBeforeAndInvalidateAllPointers(Iterator at, size_t count) { |
| 138 helper_.InsertBeforeAndInvalidateAllPointers(&at, count); | 138 helper_.InsertBeforeAndInvalidateAllPointers(&at, count); |
| 139 Iterator result = at; | 139 Iterator result = at; |
| 140 for (size_t i = 0; i < count; ++i) { | 140 for (size_t i = 0; i < count; ++i) { |
| 141 new (at.item_iterator) DerivedElementType(); | 141 new (at.item_iterator) DerivedElementType(); |
| 142 ++at; | 142 ++at; |
| 143 } | 143 } |
| 144 return result; | 144 return result; |
| 145 } | 145 } |
| 146 | 146 |
| 147 ListContainer& operator=(ListContainer&& other) { | |
|
dcheng
2016/06/16 20:57:41
Even if you don't need it now, it's better form to
Fady Samuel
2016/06/16 22:56:29
Agreed. Done.
| |
| 148 helper_.data_.swap(other.helper_.data_); | |
| 149 return *this; | |
| 150 } | |
| 151 | |
| 147 template <typename DerivedElementType> | 152 template <typename DerivedElementType> |
| 148 void swap(ListContainer<DerivedElementType>& other) { | 153 void swap(ListContainer<DerivedElementType>& other) { |
| 149 helper_.data_.swap(other.helper_.data_); | 154 helper_.data_.swap(other.helper_.data_); |
| 150 } | 155 } |
| 151 | 156 |
| 152 // Appends a new item without copying. The original item will not be | 157 // Appends a new item without copying. The original item will not be |
| 153 // destructed and will be replaced with a new DerivedElementType. The | 158 // destructed and will be replaced with a new DerivedElementType. The |
| 154 // DerivedElementType does not have to match the moved type as a full block | 159 // DerivedElementType does not have to match the moved type as a full block |
| 155 // of memory will be moved (up to MaxSizeForDerivedClass()). A pointer to | 160 // of memory will be moved (up to MaxSizeForDerivedClass()). A pointer to |
| 156 // the moved element is returned. | 161 // the moved element is returned. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 343 |
| 339 private: | 344 private: |
| 340 ListContainerHelper helper_; | 345 ListContainerHelper helper_; |
| 341 | 346 |
| 342 DISALLOW_COPY_AND_ASSIGN(ListContainer); | 347 DISALLOW_COPY_AND_ASSIGN(ListContainer); |
| 343 }; | 348 }; |
| 344 | 349 |
| 345 } // namespace cc | 350 } // namespace cc |
| 346 | 351 |
| 347 #endif // CC_BASE_LIST_CONTAINER_H_ | 352 #endif // CC_BASE_LIST_CONTAINER_H_ |
| OLD | NEW |