| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 ListContainer_h | 5 #ifndef ListContainer_h |
| 6 #define ListContainer_h | 6 #define ListContainer_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Forward.h" | 9 #include "wtf/Forward.h" |
| 10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 // Construct a new element on top of an existing one. | 259 // Construct a new element on top of an existing one. |
| 260 template <typename DerivedElementType> | 260 template <typename DerivedElementType> |
| 261 DerivedElementType* replaceExistingElement(Iterator at) | 261 DerivedElementType* replaceExistingElement(Iterator at) |
| 262 { | 262 { |
| 263 at->~BaseElementType(); | 263 at->~BaseElementType(); |
| 264 return new (*at) DerivedElementType(); | 264 return new (*at) DerivedElementType(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 template <typename DerivedElementType> |
| 268 void swap(ListContainer<DerivedElementType>& other) |
| 269 { |
| 270 m_data.swap(other.m_data); |
| 271 } |
| 272 |
| 267 // Appends a new item without copying. The original item will not be | 273 // Appends a new item without copying. The original item will not be |
| 268 // destructed and will be replaced with a new DerivedElementType. The | 274 // destructed and will be replaced with a new DerivedElementType. The |
| 269 // DerivedElementType does not have to match the moved type as a full block | 275 // DerivedElementType does not have to match the moved type as a full block |
| 270 // of memory will be moved (up to maxSizeForDerivedClass()). | 276 // of memory will be moved (up to maxSizeForDerivedClass()). |
| 271 template <typename DerivedElementType> | 277 template <typename DerivedElementType> |
| 272 void appendByMoving(DerivedElementType* item) | 278 void appendByMoving(DerivedElementType* item) |
| 273 { | 279 { |
| 274 size_t maxSize = maxSizeForDerivedClass(); | 280 size_t maxSize = maxSizeForDerivedClass(); |
| 275 void* newItem = allocate(maxSize); | 281 void* newItem = allocate(maxSize); |
| 276 memcpy(newItem, static_cast<void*>(item), maxSize); | 282 memcpy(newItem, static_cast<void*>(item), maxSize); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 explicit ConstReverseIterator(ListContainerBase::ConstReverseIterator ba
seIterator) | 435 explicit ConstReverseIterator(ListContainerBase::ConstReverseIterator ba
seIterator) |
| 430 : ListContainerBase::ConstReverseIterator(baseIterator) {} | 436 : ListContainerBase::ConstReverseIterator(baseIterator) {} |
| 431 friend ConstReverseIterator ListContainer<BaseElementType>::crbegin() co
nst; | 437 friend ConstReverseIterator ListContainer<BaseElementType>::crbegin() co
nst; |
| 432 friend ConstReverseIterator ListContainer<BaseElementType>::crend() cons
t; | 438 friend ConstReverseIterator ListContainer<BaseElementType>::crend() cons
t; |
| 433 }; | 439 }; |
| 434 }; | 440 }; |
| 435 | 441 |
| 436 } // namespace blink | 442 } // namespace blink |
| 437 | 443 |
| 438 #endif // ListContainer_h | 444 #endif // ListContainer_h |
| OLD | NEW |