| 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" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 const size_t kDefaultNumElementTypesToReserve = 32; | 13 const size_t kDefaultNumElementTypesToReserve = 32; |
| 14 } // namespace | 14 } // namespace |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 // ListContainerCharAllocator | 18 // ListContainerCharAllocator |
| 19 //////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////// |
| 20 // This class deals only with char* and void*. It does allocation and passing | 20 // This class deals only with char* and void*. It does allocation and passing |
| 21 // out raw pointers, as well as memory deallocation when being destroyed. | 21 // out raw pointers, as well as memory deallocation when being destroyed. |
| 22 class ListContainerBase::ListContainerCharAllocator { | 22 class ListContainerHelper::ListContainerCharAllocator { |
| 23 public: | 23 public: |
| 24 // ListContainerCharAllocator::InnerList | 24 // ListContainerCharAllocator::InnerList |
| 25 ///////////////////////////////////////////// | 25 ///////////////////////////////////////////// |
| 26 // This class holds the raw memory chunk, as well as information about its | 26 // This class holds the raw memory chunk, as well as information about its |
| 27 // size and availability. | 27 // size and availability. |
| 28 struct InnerList { | 28 struct InnerList { |
| 29 scoped_ptr<char[]> data; | 29 scoped_ptr<char[]> data; |
| 30 // The number of elements in total the memory can hold. The difference | 30 // The number of elements in total the memory can hold. The difference |
| 31 // between capacity and size is the how many more elements this list can | 31 // between capacity and size is the how many more elements this list can |
| 32 // hold. | 32 // hold. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 InnerList* list = storage_[position->vector_index]; | 178 InnerList* list = storage_[position->vector_index]; |
| 179 char* item_iterator = position->item_iterator; | 179 char* item_iterator = position->item_iterator; |
| 180 if (item_iterator == list->LastElement()) | 180 if (item_iterator == list->LastElement()) |
| 181 position->Increment(); | 181 position->Increment(); |
| 182 | 182 |
| 183 list->Erase(item_iterator); | 183 list->Erase(item_iterator); |
| 184 // TODO(weiliangc): Free the InnerList if it is empty. | 184 // TODO(weiliangc): Free the InnerList if it is empty. |
| 185 --size_; | 185 --size_; |
| 186 } | 186 } |
| 187 | 187 |
| 188 void InsertBefore(ListContainerBase::Iterator* position, size_t count) { | 188 void InsertBefore(ListContainerHelper::Iterator* position, size_t count) { |
| 189 if (!count) | 189 if (!count) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 // If |position| is End(), then append |count| elements at the end. This | 192 // If |position| is End(), then append |count| elements at the end. This |
| 193 // will happen to not invalidate any iterators or memory. | 193 // will happen to not invalidate any iterators or memory. |
| 194 if (!position->item_iterator) { | 194 if (!position->item_iterator) { |
| 195 // Set |position| to be the first inserted element. | 195 // Set |position| to be the first inserted element. |
| 196 Allocate(); | 196 Allocate(); |
| 197 position->vector_index = storage_.size() - 1; | 197 position->vector_index = storage_.size() - 1; |
| 198 position->item_iterator = storage_[position->vector_index]->LastElement(); | 198 position->item_iterator = storage_[position->vector_index]->LastElement(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 size_t last_list_index_; | 256 size_t last_list_index_; |
| 257 | 257 |
| 258 // This is equivalent to |storage_[last_list_index_]|. | 258 // This is equivalent to |storage_[last_list_index_]|. |
| 259 InnerList* last_list_; | 259 InnerList* last_list_; |
| 260 | 260 |
| 261 DISALLOW_COPY_AND_ASSIGN(ListContainerCharAllocator); | 261 DISALLOW_COPY_AND_ASSIGN(ListContainerCharAllocator); |
| 262 }; | 262 }; |
| 263 | 263 |
| 264 // PositionInListContainerCharAllocator | 264 // PositionInListContainerCharAllocator |
| 265 ////////////////////////////////////////////////////// | 265 ////////////////////////////////////////////////////// |
| 266 ListContainerBase::PositionInListContainerCharAllocator:: | 266 ListContainerHelper::PositionInListContainerCharAllocator:: |
| 267 PositionInListContainerCharAllocator( | 267 PositionInListContainerCharAllocator( |
| 268 const ListContainerBase::PositionInListContainerCharAllocator& other) | 268 const ListContainerHelper::PositionInListContainerCharAllocator& other) |
| 269 : ptr_to_container(other.ptr_to_container), | 269 : ptr_to_container(other.ptr_to_container), |
| 270 vector_index(other.vector_index), | 270 vector_index(other.vector_index), |
| 271 item_iterator(other.item_iterator) { | 271 item_iterator(other.item_iterator) {} |
| 272 } | |
| 273 | 272 |
| 274 ListContainerBase::PositionInListContainerCharAllocator:: | 273 ListContainerHelper::PositionInListContainerCharAllocator:: |
| 275 PositionInListContainerCharAllocator( | 274 PositionInListContainerCharAllocator( |
| 276 ListContainerBase::ListContainerCharAllocator* container, | 275 ListContainerHelper::ListContainerCharAllocator* container, |
| 277 size_t vector_ind, | 276 size_t vector_ind, |
| 278 char* item_iter) | 277 char* item_iter) |
| 279 : ptr_to_container(container), | 278 : ptr_to_container(container), |
| 280 vector_index(vector_ind), | 279 vector_index(vector_ind), |
| 281 item_iterator(item_iter) { | 280 item_iterator(item_iter) {} |
| 282 } | |
| 283 | 281 |
| 284 bool ListContainerBase::PositionInListContainerCharAllocator::operator==( | 282 bool ListContainerHelper::PositionInListContainerCharAllocator::operator==( |
| 285 const ListContainerBase::PositionInListContainerCharAllocator& other) | 283 const ListContainerHelper::PositionInListContainerCharAllocator& other) |
| 286 const { | 284 const { |
| 287 DCHECK_EQ(ptr_to_container, other.ptr_to_container); | 285 DCHECK_EQ(ptr_to_container, other.ptr_to_container); |
| 288 return vector_index == other.vector_index && | 286 return vector_index == other.vector_index && |
| 289 item_iterator == other.item_iterator; | 287 item_iterator == other.item_iterator; |
| 290 } | 288 } |
| 291 | 289 |
| 292 bool ListContainerBase::PositionInListContainerCharAllocator::operator!=( | 290 bool ListContainerHelper::PositionInListContainerCharAllocator::operator!=( |
| 293 const ListContainerBase::PositionInListContainerCharAllocator& other) | 291 const ListContainerHelper::PositionInListContainerCharAllocator& other) |
| 294 const { | 292 const { |
| 295 return !(*this == other); | 293 return !(*this == other); |
| 296 } | 294 } |
| 297 | 295 |
| 298 ListContainerBase::PositionInListContainerCharAllocator | 296 ListContainerHelper::PositionInListContainerCharAllocator |
| 299 ListContainerBase::PositionInListContainerCharAllocator::Increment() { | 297 ListContainerHelper::PositionInListContainerCharAllocator::Increment() { |
| 300 ListContainerCharAllocator::InnerList* list = | 298 ListContainerCharAllocator::InnerList* list = |
| 301 ptr_to_container->InnerListById(vector_index); | 299 ptr_to_container->InnerListById(vector_index); |
| 302 if (item_iterator == list->LastElement()) { | 300 if (item_iterator == list->LastElement()) { |
| 303 ++vector_index; | 301 ++vector_index; |
| 304 while (vector_index < ptr_to_container->list_count()) { | 302 while (vector_index < ptr_to_container->list_count()) { |
| 305 if (ptr_to_container->InnerListById(vector_index)->size != 0) | 303 if (ptr_to_container->InnerListById(vector_index)->size != 0) |
| 306 break; | 304 break; |
| 307 ++vector_index; | 305 ++vector_index; |
| 308 } | 306 } |
| 309 if (vector_index < ptr_to_container->list_count()) | 307 if (vector_index < ptr_to_container->list_count()) |
| 310 item_iterator = ptr_to_container->InnerListById(vector_index)->Begin(); | 308 item_iterator = ptr_to_container->InnerListById(vector_index)->Begin(); |
| 311 else | 309 else |
| 312 item_iterator = NULL; | 310 item_iterator = NULL; |
| 313 } else { | 311 } else { |
| 314 item_iterator += list->step; | 312 item_iterator += list->step; |
| 315 } | 313 } |
| 316 return *this; | 314 return *this; |
| 317 } | 315 } |
| 318 | 316 |
| 319 ListContainerBase::PositionInListContainerCharAllocator | 317 ListContainerHelper::PositionInListContainerCharAllocator |
| 320 ListContainerBase::PositionInListContainerCharAllocator::ReverseIncrement() { | 318 ListContainerHelper::PositionInListContainerCharAllocator::ReverseIncrement() { |
| 321 ListContainerCharAllocator::InnerList* list = | 319 ListContainerCharAllocator::InnerList* list = |
| 322 ptr_to_container->InnerListById(vector_index); | 320 ptr_to_container->InnerListById(vector_index); |
| 323 if (item_iterator == list->Begin()) { | 321 if (item_iterator == list->Begin()) { |
| 324 --vector_index; | 322 --vector_index; |
| 325 // Since |vector_index| is unsigned, we compare < list_count() instead of | 323 // Since |vector_index| is unsigned, we compare < list_count() instead of |
| 326 // comparing >= 0, as the variable will wrap around when it goes out of | 324 // comparing >= 0, as the variable will wrap around when it goes out of |
| 327 // range (below 0). | 325 // range (below 0). |
| 328 while (vector_index < ptr_to_container->list_count()) { | 326 while (vector_index < ptr_to_container->list_count()) { |
| 329 if (ptr_to_container->InnerListById(vector_index)->size != 0) | 327 if (ptr_to_container->InnerListById(vector_index)->size != 0) |
| 330 break; | 328 break; |
| 331 --vector_index; | 329 --vector_index; |
| 332 } | 330 } |
| 333 if (vector_index < ptr_to_container->list_count()) { | 331 if (vector_index < ptr_to_container->list_count()) { |
| 334 item_iterator = | 332 item_iterator = |
| 335 ptr_to_container->InnerListById(vector_index)->LastElement(); | 333 ptr_to_container->InnerListById(vector_index)->LastElement(); |
| 336 } else { | 334 } else { |
| 337 item_iterator = NULL; | 335 item_iterator = NULL; |
| 338 } | 336 } |
| 339 } else { | 337 } else { |
| 340 item_iterator -= list->step; | 338 item_iterator -= list->step; |
| 341 } | 339 } |
| 342 return *this; | 340 return *this; |
| 343 } | 341 } |
| 344 | 342 |
| 345 // ListContainerBase | 343 // ListContainerHelper |
| 346 //////////////////////////////////////////// | 344 //////////////////////////////////////////// |
| 347 ListContainerBase::ListContainerBase(size_t max_size_for_derived_class) | 345 ListContainerHelper::ListContainerHelper(size_t max_size_for_derived_class) |
| 348 : data_(new ListContainerCharAllocator(max_size_for_derived_class)) { | 346 : data_(new ListContainerCharAllocator(max_size_for_derived_class)) {} |
| 349 } | |
| 350 | 347 |
| 351 ListContainerBase::ListContainerBase(size_t max_size_for_derived_class, | 348 ListContainerHelper::ListContainerHelper(size_t max_size_for_derived_class, |
| 352 size_t num_of_elements_to_reserve_for) | 349 size_t num_of_elements_to_reserve_for) |
| 353 : data_(new ListContainerCharAllocator(max_size_for_derived_class, | 350 : data_(new ListContainerCharAllocator(max_size_for_derived_class, |
| 354 num_of_elements_to_reserve_for)) { | 351 num_of_elements_to_reserve_for)) {} |
| 355 } | |
| 356 | 352 |
| 357 ListContainerBase::~ListContainerBase() { | 353 ListContainerHelper::~ListContainerHelper() {} |
| 358 } | |
| 359 | 354 |
| 360 void ListContainerBase::RemoveLast() { | 355 void ListContainerHelper::RemoveLast() { |
| 361 data_->RemoveLast(); | 356 data_->RemoveLast(); |
| 362 } | 357 } |
| 363 | 358 |
| 364 void ListContainerBase::EraseAndInvalidateAllPointers( | 359 void ListContainerHelper::EraseAndInvalidateAllPointers( |
| 365 ListContainerBase::Iterator* position) { | 360 ListContainerHelper::Iterator* position) { |
| 366 data_->Erase(position); | 361 data_->Erase(position); |
| 367 } | 362 } |
| 368 | 363 |
| 369 void ListContainerBase::InsertBeforeAndInvalidateAllPointers( | 364 void ListContainerHelper::InsertBeforeAndInvalidateAllPointers( |
| 370 ListContainerBase::Iterator* position, | 365 ListContainerHelper::Iterator* position, |
| 371 size_t count) { | 366 size_t count) { |
| 372 data_->InsertBefore(position, count); | 367 data_->InsertBefore(position, count); |
| 373 } | 368 } |
| 374 | 369 |
| 375 ListContainerBase::ConstReverseIterator ListContainerBase::crbegin() const { | 370 ListContainerHelper::ConstReverseIterator ListContainerHelper::crbegin() const { |
| 376 if (data_->IsEmpty()) | 371 if (data_->IsEmpty()) |
| 377 return crend(); | 372 return crend(); |
| 378 | 373 |
| 379 size_t id = data_->LastInnerListId(); | 374 size_t id = data_->LastInnerListId(); |
| 380 return ConstReverseIterator(data_.get(), id, | 375 return ConstReverseIterator(data_.get(), id, |
| 381 data_->InnerListById(id)->LastElement(), 0); | 376 data_->InnerListById(id)->LastElement(), 0); |
| 382 } | 377 } |
| 383 | 378 |
| 384 ListContainerBase::ConstReverseIterator ListContainerBase::crend() const { | 379 ListContainerHelper::ConstReverseIterator ListContainerHelper::crend() const { |
| 385 return ConstReverseIterator(data_.get(), static_cast<size_t>(-1), NULL, | 380 return ConstReverseIterator(data_.get(), static_cast<size_t>(-1), NULL, |
| 386 size()); | 381 size()); |
| 387 } | 382 } |
| 388 | 383 |
| 389 ListContainerBase::ReverseIterator ListContainerBase::rbegin() { | 384 ListContainerHelper::ReverseIterator ListContainerHelper::rbegin() { |
| 390 if (data_->IsEmpty()) | 385 if (data_->IsEmpty()) |
| 391 return rend(); | 386 return rend(); |
| 392 | 387 |
| 393 size_t id = data_->LastInnerListId(); | 388 size_t id = data_->LastInnerListId(); |
| 394 return ReverseIterator(data_.get(), id, | 389 return ReverseIterator(data_.get(), id, |
| 395 data_->InnerListById(id)->LastElement(), 0); | 390 data_->InnerListById(id)->LastElement(), 0); |
| 396 } | 391 } |
| 397 | 392 |
| 398 ListContainerBase::ReverseIterator ListContainerBase::rend() { | 393 ListContainerHelper::ReverseIterator ListContainerHelper::rend() { |
| 399 return ReverseIterator(data_.get(), static_cast<size_t>(-1), NULL, size()); | 394 return ReverseIterator(data_.get(), static_cast<size_t>(-1), NULL, size()); |
| 400 } | 395 } |
| 401 | 396 |
| 402 ListContainerBase::ConstIterator ListContainerBase::cbegin() const { | 397 ListContainerHelper::ConstIterator ListContainerHelper::cbegin() const { |
| 403 if (data_->IsEmpty()) | 398 if (data_->IsEmpty()) |
| 404 return cend(); | 399 return cend(); |
| 405 | 400 |
| 406 size_t id = data_->FirstInnerListId(); | 401 size_t id = data_->FirstInnerListId(); |
| 407 return ConstIterator(data_.get(), id, data_->InnerListById(id)->Begin(), 0); | 402 return ConstIterator(data_.get(), id, data_->InnerListById(id)->Begin(), 0); |
| 408 } | 403 } |
| 409 | 404 |
| 410 ListContainerBase::ConstIterator ListContainerBase::cend() const { | 405 ListContainerHelper::ConstIterator ListContainerHelper::cend() const { |
| 411 if (data_->IsEmpty()) | 406 if (data_->IsEmpty()) |
| 412 return ConstIterator(data_.get(), 0, NULL, size()); | 407 return ConstIterator(data_.get(), 0, NULL, size()); |
| 413 | 408 |
| 414 size_t id = data_->list_count(); | 409 size_t id = data_->list_count(); |
| 415 return ConstIterator(data_.get(), id, NULL, size()); | 410 return ConstIterator(data_.get(), id, NULL, size()); |
| 416 } | 411 } |
| 417 | 412 |
| 418 ListContainerBase::Iterator ListContainerBase::begin() { | 413 ListContainerHelper::Iterator ListContainerHelper::begin() { |
| 419 if (data_->IsEmpty()) | 414 if (data_->IsEmpty()) |
| 420 return end(); | 415 return end(); |
| 421 | 416 |
| 422 size_t id = data_->FirstInnerListId(); | 417 size_t id = data_->FirstInnerListId(); |
| 423 return Iterator(data_.get(), id, data_->InnerListById(id)->Begin(), 0); | 418 return Iterator(data_.get(), id, data_->InnerListById(id)->Begin(), 0); |
| 424 } | 419 } |
| 425 | 420 |
| 426 ListContainerBase::Iterator ListContainerBase::end() { | 421 ListContainerHelper::Iterator ListContainerHelper::end() { |
| 427 if (data_->IsEmpty()) | 422 if (data_->IsEmpty()) |
| 428 return Iterator(data_.get(), 0, NULL, size()); | 423 return Iterator(data_.get(), 0, NULL, size()); |
| 429 | 424 |
| 430 size_t id = data_->list_count(); | 425 size_t id = data_->list_count(); |
| 431 return Iterator(data_.get(), id, NULL, size()); | 426 return Iterator(data_.get(), id, NULL, size()); |
| 432 } | 427 } |
| 433 | 428 |
| 434 ListContainerBase::ConstIterator ListContainerBase::IteratorAt( | 429 ListContainerHelper::ConstIterator ListContainerHelper::IteratorAt( |
| 435 size_t index) const { | 430 size_t index) const { |
| 436 DCHECK_LT(index, size()); | 431 DCHECK_LT(index, size()); |
| 437 size_t original_index = index; | 432 size_t original_index = index; |
| 438 size_t list_index; | 433 size_t list_index; |
| 439 for (list_index = 0; list_index < data_->list_count(); ++list_index) { | 434 for (list_index = 0; list_index < data_->list_count(); ++list_index) { |
| 440 size_t current_size = data_->InnerListById(list_index)->size; | 435 size_t current_size = data_->InnerListById(list_index)->size; |
| 441 if (index < current_size) | 436 if (index < current_size) |
| 442 break; | 437 break; |
| 443 index -= current_size; | 438 index -= current_size; |
| 444 } | 439 } |
| 445 return ConstIterator(data_.get(), list_index, | 440 return ConstIterator(data_.get(), list_index, |
| 446 data_->InnerListById(list_index)->ElementAt(index), | 441 data_->InnerListById(list_index)->ElementAt(index), |
| 447 original_index); | 442 original_index); |
| 448 } | 443 } |
| 449 | 444 |
| 450 ListContainerBase::Iterator ListContainerBase::IteratorAt(size_t index) { | 445 ListContainerHelper::Iterator ListContainerHelper::IteratorAt(size_t index) { |
| 451 DCHECK_LT(index, size()); | 446 DCHECK_LT(index, size()); |
| 452 size_t original_index = index; | 447 size_t original_index = index; |
| 453 size_t list_index; | 448 size_t list_index; |
| 454 for (list_index = 0; list_index < data_->list_count(); ++list_index) { | 449 for (list_index = 0; list_index < data_->list_count(); ++list_index) { |
| 455 size_t current_size = data_->InnerListById(list_index)->size; | 450 size_t current_size = data_->InnerListById(list_index)->size; |
| 456 if (index < current_size) | 451 if (index < current_size) |
| 457 break; | 452 break; |
| 458 index -= current_size; | 453 index -= current_size; |
| 459 } | 454 } |
| 460 return Iterator(data_.get(), list_index, | 455 return Iterator(data_.get(), list_index, |
| 461 data_->InnerListById(list_index)->ElementAt(index), | 456 data_->InnerListById(list_index)->ElementAt(index), |
| 462 original_index); | 457 original_index); |
| 463 } | 458 } |
| 464 | 459 |
| 465 void* ListContainerBase::Allocate(size_t size_of_actual_element_in_bytes) { | 460 void* ListContainerHelper::Allocate(size_t size_of_actual_element_in_bytes) { |
| 466 DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size()); | 461 DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size()); |
| 467 return data_->Allocate(); | 462 return data_->Allocate(); |
| 468 } | 463 } |
| 469 | 464 |
| 470 size_t ListContainerBase::size() const { | 465 size_t ListContainerHelper::size() const { |
| 471 return data_->size(); | 466 return data_->size(); |
| 472 } | 467 } |
| 473 | 468 |
| 474 bool ListContainerBase::empty() const { | 469 bool ListContainerHelper::empty() const { |
| 475 return data_->IsEmpty(); | 470 return data_->IsEmpty(); |
| 476 } | 471 } |
| 477 | 472 |
| 478 size_t ListContainerBase::MaxSizeForDerivedClass() const { | 473 size_t ListContainerHelper::MaxSizeForDerivedClass() const { |
| 479 return data_->element_size(); | 474 return data_->element_size(); |
| 480 } | 475 } |
| 481 | 476 |
| 482 size_t ListContainerBase::GetCapacityInBytes() const { | 477 size_t ListContainerHelper::GetCapacityInBytes() const { |
| 483 return data_->Capacity() * data_->element_size(); | 478 return data_->Capacity() * data_->element_size(); |
| 484 } | 479 } |
| 485 | 480 |
| 486 void ListContainerBase::clear() { | 481 void ListContainerHelper::clear() { |
| 487 data_->Clear(); | 482 data_->Clear(); |
| 488 } | 483 } |
| 489 | 484 |
| 490 size_t ListContainerBase::AvailableSizeWithoutAnotherAllocationForTesting() | 485 size_t ListContainerHelper::AvailableSizeWithoutAnotherAllocationForTesting() |
| 491 const { | 486 const { |
| 492 return data_->NumAvailableElementsInLastList(); | 487 return data_->NumAvailableElementsInLastList(); |
| 493 } | 488 } |
| 494 | 489 |
| 495 // ListContainerBase::Iterator | 490 // ListContainerHelper::Iterator |
| 496 ///////////////////////////////////////////////// | 491 ///////////////////////////////////////////////// |
| 497 ListContainerBase::Iterator::Iterator(ListContainerCharAllocator* container, | 492 ListContainerHelper::Iterator::Iterator(ListContainerCharAllocator* container, |
| 498 size_t vector_ind, | 493 size_t vector_ind, |
| 499 char* item_iter, | 494 char* item_iter, |
| 500 size_t index) | 495 size_t index) |
| 501 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), | 496 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), |
| 502 index_(index) { | 497 index_(index) {} |
| 503 } | |
| 504 | 498 |
| 505 ListContainerBase::Iterator::~Iterator() { | 499 ListContainerHelper::Iterator::~Iterator() {} |
| 506 } | |
| 507 | 500 |
| 508 size_t ListContainerBase::Iterator::index() const { | 501 size_t ListContainerHelper::Iterator::index() const { |
| 509 return index_; | 502 return index_; |
| 510 } | 503 } |
| 511 | 504 |
| 512 // ListContainerBase::ConstIterator | 505 // ListContainerHelper::ConstIterator |
| 513 ///////////////////////////////////////////////// | 506 ///////////////////////////////////////////////// |
| 514 ListContainerBase::ConstIterator::ConstIterator( | 507 ListContainerHelper::ConstIterator::ConstIterator( |
| 515 const ListContainerBase::Iterator& other) | 508 const ListContainerHelper::Iterator& other) |
| 516 : PositionInListContainerCharAllocator(other), index_(other.index()) { | 509 : PositionInListContainerCharAllocator(other), index_(other.index()) {} |
| 517 } | |
| 518 | 510 |
| 519 ListContainerBase::ConstIterator::ConstIterator( | 511 ListContainerHelper::ConstIterator::ConstIterator( |
| 520 ListContainerCharAllocator* container, | 512 ListContainerCharAllocator* container, |
| 521 size_t vector_ind, | 513 size_t vector_ind, |
| 522 char* item_iter, | 514 char* item_iter, |
| 523 size_t index) | 515 size_t index) |
| 524 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), | 516 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), |
| 525 index_(index) { | 517 index_(index) {} |
| 526 } | |
| 527 | 518 |
| 528 ListContainerBase::ConstIterator::~ConstIterator() { | 519 ListContainerHelper::ConstIterator::~ConstIterator() {} |
| 529 } | |
| 530 | 520 |
| 531 size_t ListContainerBase::ConstIterator::index() const { | 521 size_t ListContainerHelper::ConstIterator::index() const { |
| 532 return index_; | 522 return index_; |
| 533 } | 523 } |
| 534 | 524 |
| 535 // ListContainerBase::ReverseIterator | 525 // ListContainerHelper::ReverseIterator |
| 536 ///////////////////////////////////////////////// | 526 ///////////////////////////////////////////////// |
| 537 ListContainerBase::ReverseIterator::ReverseIterator( | 527 ListContainerHelper::ReverseIterator::ReverseIterator( |
| 538 ListContainerCharAllocator* container, | 528 ListContainerCharAllocator* container, |
| 539 size_t vector_ind, | 529 size_t vector_ind, |
| 540 char* item_iter, | 530 char* item_iter, |
| 541 size_t index) | 531 size_t index) |
| 542 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), | 532 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), |
| 543 index_(index) { | 533 index_(index) {} |
| 544 } | |
| 545 | 534 |
| 546 ListContainerBase::ReverseIterator::~ReverseIterator() { | 535 ListContainerHelper::ReverseIterator::~ReverseIterator() {} |
| 547 } | |
| 548 | 536 |
| 549 size_t ListContainerBase::ReverseIterator::index() const { | 537 size_t ListContainerHelper::ReverseIterator::index() const { |
| 550 return index_; | 538 return index_; |
| 551 } | 539 } |
| 552 | 540 |
| 553 // ListContainerBase::ConstReverseIterator | 541 // ListContainerHelper::ConstReverseIterator |
| 554 ///////////////////////////////////////////////// | 542 ///////////////////////////////////////////////// |
| 555 ListContainerBase::ConstReverseIterator::ConstReverseIterator( | 543 ListContainerHelper::ConstReverseIterator::ConstReverseIterator( |
| 556 const ListContainerBase::ReverseIterator& other) | 544 const ListContainerHelper::ReverseIterator& other) |
| 557 : PositionInListContainerCharAllocator(other), index_(other.index()) { | 545 : PositionInListContainerCharAllocator(other), index_(other.index()) {} |
| 558 } | |
| 559 | 546 |
| 560 ListContainerBase::ConstReverseIterator::ConstReverseIterator( | 547 ListContainerHelper::ConstReverseIterator::ConstReverseIterator( |
| 561 ListContainerCharAllocator* container, | 548 ListContainerCharAllocator* container, |
| 562 size_t vector_ind, | 549 size_t vector_ind, |
| 563 char* item_iter, | 550 char* item_iter, |
| 564 size_t index) | 551 size_t index) |
| 565 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), | 552 : PositionInListContainerCharAllocator(container, vector_ind, item_iter), |
| 566 index_(index) { | 553 index_(index) {} |
| 567 } | |
| 568 | 554 |
| 569 ListContainerBase::ConstReverseIterator::~ConstReverseIterator() { | 555 ListContainerHelper::ConstReverseIterator::~ConstReverseIterator() {} |
| 570 } | |
| 571 | 556 |
| 572 size_t ListContainerBase::ConstReverseIterator::index() const { | 557 size_t ListContainerHelper::ConstReverseIterator::index() const { |
| 573 return index_; | 558 return index_; |
| 574 } | 559 } |
| 575 | 560 |
| 576 } // namespace cc | 561 } // namespace cc |
| OLD | NEW |