| 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 "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 DerivedElementType(*source); | 281 DerivedElementType(*source); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // Construct a new element on top of an existing one. | 284 // Construct a new element on top of an existing one. |
| 285 template <typename DerivedElementType> | 285 template <typename DerivedElementType> |
| 286 DerivedElementType* ReplaceExistingElement(Iterator at) { | 286 DerivedElementType* ReplaceExistingElement(Iterator at) { |
| 287 at->~BaseElementType(); | 287 at->~BaseElementType(); |
| 288 return new (*at) DerivedElementType(); | 288 return new (*at) DerivedElementType(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 template <typename DerivedElementType> |
| 292 void swap(ListContainer<DerivedElementType>& other) { |
| 293 data_.swap(other.data_); |
| 294 } |
| 295 |
| 291 // Appends a new item without copying. The original item will not be | 296 // Appends a new item without copying. The original item will not be |
| 292 // destructed and will be replaced with a new DerivedElementType. The | 297 // destructed and will be replaced with a new DerivedElementType. The |
| 293 // DerivedElementType does not have to match the moved type as a full block | 298 // DerivedElementType does not have to match the moved type as a full block |
| 294 // of memory will be moved (up to MaxSizeForDerivedClass()). | 299 // of memory will be moved (up to MaxSizeForDerivedClass()). |
| 295 template <typename DerivedElementType> | 300 template <typename DerivedElementType> |
| 296 void AppendByMoving(DerivedElementType* item) { | 301 void AppendByMoving(DerivedElementType* item) { |
| 297 size_t max_size_for_derived_class = MaxSizeForDerivedClass(); | 302 size_t max_size_for_derived_class = MaxSizeForDerivedClass(); |
| 298 void* new_item = Allocate(max_size_for_derived_class); | 303 void* new_item = Allocate(max_size_for_derived_class); |
| 299 memcpy(new_item, static_cast<void*>(item), max_size_for_derived_class); | 304 memcpy(new_item, static_cast<void*>(item), max_size_for_derived_class); |
| 300 // Construct a new element in-place so it can be destructed safely. | 305 // Construct a new element in-place so it can be destructed safely. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 ListContainerBase::ConstReverseIterator base_iterator) | 469 ListContainerBase::ConstReverseIterator base_iterator) |
| 465 : ListContainerBase::ConstReverseIterator(base_iterator) {} | 470 : ListContainerBase::ConstReverseIterator(base_iterator) {} |
| 466 friend ConstReverseIterator ListContainer<BaseElementType>::crbegin() const; | 471 friend ConstReverseIterator ListContainer<BaseElementType>::crbegin() const; |
| 467 friend ConstReverseIterator ListContainer<BaseElementType>::crend() const; | 472 friend ConstReverseIterator ListContainer<BaseElementType>::crend() const; |
| 468 }; | 473 }; |
| 469 }; | 474 }; |
| 470 | 475 |
| 471 } // namespace cc | 476 } // namespace cc |
| 472 | 477 |
| 473 #endif // CC_BASE_LIST_CONTAINER_H_ | 478 #endif // CC_BASE_LIST_CONTAINER_H_ |
| OLD | NEW |