Changeset db05684 in mainline
- Timestamp:
- 2018-07-05T21:41:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2353857
- Parents:
- 289c954a
- git-author:
- Dzejrou <dzejrou@…> (2018-04-11 21:07:02)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/deque.hpp
r289c954a rdb05684 425 425 fini_(); 426 426 427 prepare_for_size_(other.size_);428 init_();429 427 copy_from_range_(other.begin(), other.end()); 430 428 … … 444 442 fini_(); 445 443 446 prepare_for_size_(init.size());447 init_();448 444 copy_from_range_(init.begin(), init.end()); 449 445 … … 454 450 void assign(InputIterator first, InputIterator last) 455 451 { 456 // TODO: implement452 copy_from_range_(first, last); 457 453 } 458 454 459 455 void assign(size_type n, const T& value) 460 456 { 461 // TODO: implement 457 prepare_for_size_(n); 458 init_(); 459 size_ = n; 460 461 auto it = begin(); 462 for (size_type i = size_type{}; i < n; ++i) 463 *it++ = value; 462 464 } 463 465 464 466 void assign(initializer_list<T> init) 465 467 { 466 // TODO: implement468 copy_from_range_(init.begin(), init.end()); 467 469 } 468 470 … … 543 545 size_type max_size() const noexcept 544 546 { 545 return allocator_traits< Allocator>::max_size(allocator_);547 return allocator_traits<allocator_type>::max_size(allocator_); 546 548 } 547 549 … … 643 645 void emplace_front(Args&&... args) 644 646 { 645 // TODO: implement 647 if (front_bucket_idx_ == 0) 648 add_new_bucket_front_(); 649 650 allocator_traits<allocator_type>::construct( 651 allocator_, 652 &data_[front_bucket_][--front_bucket_idx_], 653 forward<Args>(args)... 654 ); 655 656 ++size_; 646 657 } 647 658 … … 649 660 void emplace_back(Args&&... args) 650 661 { 651 // TODO: implement 662 allocator_traits<allocator_type>::construct( 663 allocator_, 664 &data_[back_bucket_][back_bucket_idx_++], 665 forward<Args>(args)... 666 ); 667 668 ++size_; 669 670 if (back_bucket_idx_ >= bucket_size_) 671 add_new_bucket_back_(); 652 672 } 653 673 … … 838 858 bucket_count_ = bucket_capacity_ = 2; 839 859 else if (size % bucket_size_ == 0) 840 bucket_count_ = bucket_capacity_ = size / bucket_size_ + 1;860 bucket_count_ = bucket_capacity_ = size / bucket_size_ + 2; 841 861 else 842 862 bucket_count_ = bucket_capacity_ = size / bucket_size_ + 2; … … 844 864 front_bucket_ = 0; 845 865 back_bucket_ = bucket_capacity_ - 1; 866 867 front_bucket_idx_ = bucket_size_; 868 back_bucket_idx_ = size % bucket_size_; 846 869 } 847 870 … … 856 879 while (first != last) 857 880 *it++ = *first++; 858 859 // Remainder is the amount of elements in the last bucket.860 back_bucket_idx_ = size_ % bucket_size_;861 881 } 862 882
Note:
See TracChangeset
for help on using the changeset viewer.