| 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 #include "cc/base/list_container.h" | 5 #include "cc/base/list_container.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/base/scoped_ptr_vector.h" | 10 #include "cc/base/scoped_ptr_vector.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 --last_list_index_; | 164 --last_list_index_; |
| 165 last_list_ = storage_[last_list_index_]; | 165 last_list_ = storage_[last_list_index_]; |
| 166 | 166 |
| 167 // If there are now two empty inner lists, free one of them. | 167 // If there are now two empty inner lists, free one of them. |
| 168 if (last_list_index_ + 2 < storage_.size()) | 168 if (last_list_index_ + 2 < storage_.size()) |
| 169 storage_.pop_back(); | 169 storage_.pop_back(); |
| 170 } | 170 } |
| 171 --size_; | 171 --size_; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void Erase(PositionInListContainerCharAllocator position) { | 174 void Erase(PositionInListContainerCharAllocator* position) { |
| 175 DCHECK_EQ(this, position.ptr_to_container); | 175 DCHECK_EQ(this, position->ptr_to_container); |
| 176 storage_[position.vector_index]->Erase(position.item_iterator); | 176 InnerList* list = storage_[position->vector_index]; |
| 177 char* item_iterator = position->item_iterator; |
| 178 if (item_iterator == list->LastElement()) |
| 179 position->Increment(); |
| 180 list->Erase(item_iterator); |
| 177 // TODO(weiliangc): Free the InnerList if it is empty. | 181 // TODO(weiliangc): Free the InnerList if it is empty. |
| 178 --size_; | 182 --size_; |
| 179 } | 183 } |
| 180 | 184 |
| 181 void InsertBefore(ListContainerBase::Iterator* position, size_t count) { | 185 void InsertBefore(ListContainerBase::Iterator* position, size_t count) { |
| 182 if (!count) | 186 if (!count) |
| 183 return; | 187 return; |
| 184 | 188 |
| 185 // If |position| is End(), then append |count| elements at the end. This | 189 // If |position| is End(), then append |count| elements at the end. This |
| 186 // will happen to not invalidate any iterators or memory. | 190 // will happen to not invalidate any iterators or memory. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 352 } |
| 349 | 353 |
| 350 ListContainerBase::~ListContainerBase() { | 354 ListContainerBase::~ListContainerBase() { |
| 351 } | 355 } |
| 352 | 356 |
| 353 void ListContainerBase::RemoveLast() { | 357 void ListContainerBase::RemoveLast() { |
| 354 data_->RemoveLast(); | 358 data_->RemoveLast(); |
| 355 } | 359 } |
| 356 | 360 |
| 357 void ListContainerBase::EraseAndInvalidateAllPointers( | 361 void ListContainerBase::EraseAndInvalidateAllPointers( |
| 358 ListContainerBase::Iterator position) { | 362 ListContainerBase::Iterator* position) { |
| 359 data_->Erase(position); | 363 data_->Erase(position); |
| 360 } | 364 } |
| 361 | 365 |
| 362 void ListContainerBase::InsertBeforeAndInvalidateAllPointers( | 366 void ListContainerBase::InsertBeforeAndInvalidateAllPointers( |
| 363 ListContainerBase::Iterator* position, | 367 ListContainerBase::Iterator* position, |
| 364 size_t count) { | 368 size_t count) { |
| 365 data_->InsertBefore(position, count); | 369 data_->InsertBefore(position, count); |
| 366 } | 370 } |
| 367 | 371 |
| 368 ListContainerBase::ConstReverseIterator ListContainerBase::crbegin() const { | 372 ListContainerBase::ConstReverseIterator ListContainerBase::crbegin() const { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 564 } |
| 561 | 565 |
| 562 ListContainerBase::ConstReverseIterator::~ConstReverseIterator() { | 566 ListContainerBase::ConstReverseIterator::~ConstReverseIterator() { |
| 563 } | 567 } |
| 564 | 568 |
| 565 size_t ListContainerBase::ConstReverseIterator::index() const { | 569 size_t ListContainerBase::ConstReverseIterator::index() const { |
| 566 return index_; | 570 return index_; |
| 567 } | 571 } |
| 568 | 572 |
| 569 } // namespace cc | 573 } // namespace cc |
| OLD | NEW |