ORIGINAL
Loading...
Searching...
No Matches
blocksList.h
Go to the documentation of this file.
1#ifndef BLOCKSLIST_H
2#define BLOCKSLIST_H
3
4#include "baseList.h"
5#include "couple.h"
6#include "vector.h"
7
16namespace original {
29 template <typename TYPE, typename ALLOC = allocator<TYPE>>
30 class blocksList final : public baseList<TYPE, ALLOC>, public iterationStream<TYPE, blocksList<TYPE, ALLOC>> {
31 static constexpr u_integer BLOCK_MAX_SIZE = 16;
32 static constexpr u_integer POS_INIT = (BLOCK_MAX_SIZE - 1) / 2 + 1;
33
40
41 u_integer size_;
42 u_integer first_;
43 u_integer last_;
44 u_integer first_block;
45 u_integer last_block;
46
47
54 TYPE* blockArrayInit();
55
61 void blocksListInit();
62
68 void blocksListDestroy() noexcept;
69
76 [[nodiscard]] static u_integer innerIdxToAbsIdx(u_integer block, u_integer pos);
77
82 [[nodiscard]] u_integer firstAbsIdx() const;
83
88 [[nodiscard]] u_integer lastAbsIdx() const;
89
95 [[nodiscard]] integer absIdxToOuterIdx(u_integer absIdx) const;
96
102 [[nodiscard]] u_integer outerIdxToAbsIdx(integer outerIdx) const;
103
109 [[nodiscard]] static couple<u_integer, u_integer> absIdxToInnerIdx(u_integer absIdx);
110
119
125 [[nodiscard]] couple<u_integer, u_integer> outerIdxToInnerIdx(integer outerIdx) const;
126
133 [[nodiscard]] integer innerIdxToOuterIdx(u_integer block, u_integer pos) const;
134
141 TYPE& getElem(u_integer block, u_integer pos) const;
142
149 void setElem(u_integer block, u_integer pos, const TYPE& e);
150
157 [[nodiscard]] bool growNeeded(u_integer increment, bool is_first) const;
158
167
174 void addBlock(bool is_first);
175
183 void adjust(u_integer increment, bool is_first);
184
185 public:
192 class Iterator final : public baseIterator<TYPE> {
193 mutable integer cur_pos;
194 mutable integer cur_block;
195 mutable TYPE** data_;
196 const blocksList* container_;
197
206
212 bool equalPtr(const iterator<TYPE>* other) const override;
213
214 public:
215 friend blocksList;
216
221 Iterator(const Iterator& other);
222
228 Iterator& operator=(const Iterator& other);
229
234 Iterator* clone() const override;
235
240 [[nodiscard]] bool hasNext() const override;
241
246 [[nodiscard]] bool hasPrev() const override;
247
251 void next() const override;
252
256 void prev() const override;
257
262 void operator+=(integer steps) const override;
263
268 void operator-=(integer steps) const override;
269
275 integer operator-(const iterator<TYPE>& other) const override;
276
281 Iterator* getPrev() const override;
282
287 Iterator* getNext() const override;
288
293 TYPE& get() override;
294
299 TYPE get() const override;
300
305 void set(const TYPE& data) override;
306
311 [[nodiscard]] bool isValid() const override;
312
318 bool atPrev(const iterator<TYPE>* other) const override;
319
325 bool atNext(const iterator<TYPE>* other) const override;
326
331 [[nodiscard]] std::string className() const override;
332 };
333
334 friend Iterator;
335
343
348 blocksList(const std::initializer_list<TYPE>& lst);
349
354 explicit blocksList(const array<TYPE>& arr);
355
363
372
380
389
396 void swap(blocksList& other) noexcept;
397
403 TYPE get(integer index) const override;
404
409 [[nodiscard]] u_integer size() const override;
410
415 Iterator* begins() const override;
416
421 Iterator* ends() const override;
422
428 TYPE& operator[](integer index) override;
429
435 void set(integer index, const TYPE& e) override;
436
442 u_integer indexOf(const TYPE& e) const override;
443
449 void push(integer index, const TYPE& e) override;
450
456 TYPE pop(integer index) override;
457
462 void pushBegin(const TYPE& e) override;
463
468 TYPE popBegin() override;
469
474 void pushEnd(const TYPE& e) override;
475
480 TYPE popEnd() override;
481
486 [[nodiscard]] std::string className() const override;
487
491 ~blocksList() override;
492 };
493}// namespace original
494
495namespace std {
503 template<typename TYPE, typename ALLOC>
505}
506
507 template <typename TYPE, typename ALLOC>
509 {
510 this->map = vector({this->blockArrayInit()});
511 this->size_ = 0;
512 this->first_ = POS_INIT + 1;
513 this->last_ = POS_INIT;
514 this->first_block = this->map.size() / 2;
515 this->last_block = this->map.size() / 2;
516 }
517
518 template <typename TYPE, typename ALLOC>
520 {
521 for (auto* block : this->map) {
522 for (u_integer i = 0; i < BLOCK_MAX_SIZE; ++i) {
523 this->destroy(&block[i]);
524 }
525 this->deallocate(block, BLOCK_MAX_SIZE);
526 }
527 }
528
529 template <typename TYPE, typename ALLOC>
531 auto arr = this->allocate(BLOCK_MAX_SIZE);
532 for (u_integer i = 0; i < BLOCK_MAX_SIZE; i++) {
533 this->construct(&arr[i]);
534 }
535 return arr;
536 }
537
538 template <typename TYPE, typename ALLOC>
539 auto original::blocksList<TYPE, ALLOC>::innerIdxToAbsIdx(const u_integer block, const u_integer pos) -> u_integer
540 {
541 return block * BLOCK_MAX_SIZE + pos;
542 }
543
544 template <typename TYPE, typename ALLOC>
545 auto original::blocksList<TYPE, ALLOC>::firstAbsIdx() const -> u_integer
546 {
547 return innerIdxToAbsIdx(this->first_block, this->first_);
548 }
549
550 template <typename TYPE, typename ALLOC>
551 auto original::blocksList<TYPE, ALLOC>::lastAbsIdx() const -> u_integer
552 {
553 return innerIdxToAbsIdx(this->last_block, this->last_);
554 }
555
556 template <typename TYPE, typename ALLOC>
557 auto original::blocksList<TYPE, ALLOC>::absIdxToOuterIdx(const u_integer absIdx) const -> integer
558 {
559 return absIdx - this->firstAbsIdx();
560 }
561
562 template <typename TYPE, typename ALLOC>
563 auto original::blocksList<TYPE, ALLOC>::outerIdxToAbsIdx(const integer outerIdx) const -> u_integer
564 {
565 return this->firstAbsIdx() + outerIdx;
566 }
567
568 template <typename TYPE, typename ALLOC>
569 auto original::blocksList<TYPE, ALLOC>::absIdxToInnerIdx(const u_integer absIdx) -> couple<u_integer, u_integer>
570 {
571 return {absIdx / BLOCK_MAX_SIZE, absIdx % BLOCK_MAX_SIZE};
572 }
573
574 template <typename TYPE, typename ALLOC>
575 auto original::blocksList<TYPE, ALLOC>::innerIdxOffset(const u_integer block, const u_integer pos,
576 const integer offset) -> couple<u_integer, u_integer>
577 {
578 return absIdxToInnerIdx(static_cast<u_integer>(static_cast<integer>(innerIdxToAbsIdx(block, pos)) + offset));
579 }
580
581 template <typename TYPE, typename ALLOC>
582 auto original::blocksList<TYPE, ALLOC>::outerIdxToInnerIdx(const integer outerIdx) const -> couple<u_integer, u_integer>
583 {
584 return absIdxToInnerIdx(this->outerIdxToAbsIdx(outerIdx));
585 }
586
587 template <typename TYPE, typename ALLOC>
588 auto original::blocksList<TYPE, ALLOC>::innerIdxToOuterIdx(const u_integer block, const u_integer pos) const -> integer
589 {
590 return this->absIdxToOuterIdx(innerIdxToAbsIdx(block, pos));
591 }
592
593 template <typename TYPE, typename ALLOC>
594 auto original::blocksList<TYPE, ALLOC>::getElem(u_integer block, u_integer pos) const -> TYPE&
595 {
596 return this->map.get(block)[pos];
597 }
598
599 template <typename TYPE, typename ALLOC>
600 auto original::blocksList<TYPE, ALLOC>::setElem(u_integer block, u_integer pos, const TYPE& e) -> void
601 {
602 this->map.get(block)[pos] = e;
603 }
604
605 template <typename TYPE, typename ALLOC>
606 auto original::blocksList<TYPE, ALLOC>::growNeeded(const u_integer increment, bool is_first) const -> bool
607 {
608 return is_first ? firstAbsIdx() < increment
609 : lastAbsIdx() + increment > innerIdxToAbsIdx(this->map.size() - 1, BLOCK_MAX_SIZE - 1);
610 }
611
612 template <typename TYPE, typename ALLOC>
613 auto original::blocksList<TYPE, ALLOC>::moveElements(const u_integer start_block, const u_integer start_pos,
614 const u_integer len, const integer offset) -> void
615 {
616 if (offset > 0)
617 {
618 for (u_integer i = 0; i < len; i++)
619 {
620 auto idx = innerIdxOffset(start_block, start_pos, len - 1 - i);
621 auto idx_offset = innerIdxOffset(start_block, start_pos, len - 1 - i + offset);
622 this->setElem(idx_offset.first(), idx_offset.second(),
623 this->getElem(idx.first(), idx.second()));
624 }
625 }else
626 {
627 for (u_integer i = 0; i < len; i++)
628 {
629 auto idx = innerIdxOffset(start_block, start_pos, i);
630 auto idx_offset = innerIdxOffset(start_block, start_pos, i + offset);
631 this->setElem(idx_offset.first(), idx_offset.second(),
632 this->getElem(idx.first(), idx.second()));
633 }
634 }
635 }
636
637 template <typename TYPE, typename ALLOC>
638 auto original::blocksList<TYPE, ALLOC>::addBlock(bool is_first) -> void
639 {
640 auto* new_block = this->blockArrayInit();
641 is_first ? this->map.pushBegin(new_block) : this->map.pushEnd(new_block);
642 }
643
644 template <typename TYPE, typename ALLOC>
645 auto original::blocksList<TYPE, ALLOC>::adjust(const u_integer increment, const bool is_first) -> void
646 {
647 if (this->growNeeded(increment, is_first)){
648 u_integer new_blocks_cnt = increment / BLOCK_MAX_SIZE + 1;
649 for (u_integer i = 0; i < new_blocks_cnt; ++i) {
650 this->addBlock(is_first);
651 }
652 if (is_first){
653 this->first_block += new_blocks_cnt;
654 this->last_block += new_blocks_cnt;
655 }
656 }
657 }
658
659 template <typename TYPE, typename ALLOC>
660 original::blocksList<TYPE, ALLOC>::Iterator::Iterator(const integer pos, const integer block, TYPE** data_ptr, const blocksList* container)
661 : cur_pos(pos), cur_block(block), data_(data_ptr), container_(container) {}
662
663 template <typename TYPE, typename ALLOC>
664 auto original::blocksList<TYPE, ALLOC>::Iterator::equalPtr(const iterator<TYPE>* other) const -> bool
665 {
666 auto* other_it = dynamic_cast<const Iterator*>(other);
667 return other_it != nullptr
668 && this->cur_pos == other_it->cur_pos
669 && this->cur_block == other_it->cur_block
670 && this->data_ == other_it->data_
671 && this->container_ == other_it->container_;
672 }
673
674 template <typename TYPE, typename ALLOC>
679
680 template <typename TYPE, typename ALLOC>
682 {
683 if (this == &other)
684 return *this;
685
686 this->cur_pos = other.cur_pos;
687 this->cur_block = other.cur_block;
688 this->data_ = other.data_;
689 this->container_ = other.container_;
690 return *this;
691 }
692
693 template <typename TYPE, typename ALLOC>
695 {
696 return new Iterator(*this);
697 }
698
699 template <typename TYPE, typename ALLOC>
701 {
702 return blocksList::innerIdxToAbsIdx(this->cur_block, this->cur_pos) < this->container_->lastAbsIdx();
703 }
704
705 template <typename TYPE, typename ALLOC>
707 {
708 return blocksList::innerIdxToAbsIdx(this->cur_block, this->cur_pos) > this->container_->firstAbsIdx();
709 }
710
711 template <typename TYPE, typename ALLOC>
713 {
714 this->operator+=(1);
715 }
716
717 template <typename TYPE, typename ALLOC>
719 {
720 this->operator-=(1);
721 }
722
723 template <typename TYPE, typename ALLOC>
725 {
726 auto new_idx = innerIdxOffset(this->cur_block, this->cur_pos, steps);
727 this->cur_block = new_idx.first();
728 this->cur_pos = new_idx.second();
729 }
730
731 template <typename TYPE, typename ALLOC>
733 {
734 auto new_idx = innerIdxOffset(this->cur_block, this->cur_pos, -steps);
735 this->cur_block = new_idx.first();
736 this->cur_pos = new_idx.second();
737 }
738
739 template <typename TYPE, typename ALLOC>
741 {
742 auto* other_it = dynamic_cast<const Iterator*>(&other);
743 if (other_it == nullptr)
744 return this > &other ?
745 (std::numeric_limits<integer>::max)() :
746 (std::numeric_limits<integer>::min)();
747 if (this->container_ != other_it->container_)
748 return this->container_ > other_it->container_ ?
749 (std::numeric_limits<integer>::max)() :
750 (std::numeric_limits<integer>::min)();
751
752 return static_cast<integer>(innerIdxToAbsIdx(this->cur_block, this->cur_pos)) -
753 static_cast<integer>(innerIdxToAbsIdx(other_it->cur_block, other_it->cur_pos));
754 }
755
756 template <typename TYPE, typename ALLOC>
758 {
759 if (!this->isValid()) throw outOfBoundError();
760 auto* it = this->clone();
761 it->prev();
762 return it;
763 }
764
765 template <typename TYPE, typename ALLOC>
767 {
768 if (!this->isValid()) throw outOfBoundError();
769 auto* it = this->clone();
770 it->next();
771 return it;
772 }
773
774 template <typename TYPE, typename ALLOC>
776 {
777 if (!this->isValid()) throw outOfBoundError();
778 return this->data_[this->cur_block][this->cur_pos];
779 }
780
781 template <typename TYPE, typename ALLOC>
783 {
784 if (!this->isValid()) throw outOfBoundError();
785 return this->data_[this->cur_block][this->cur_pos];
786 }
787
788 template <typename TYPE, typename ALLOC>
790 {
791 if (!this->isValid()) throw outOfBoundError();
792 this->data_[this->cur_block][this->cur_pos] = data;
793 }
794
795 template <typename TYPE, typename ALLOC>
797 {
798 return this->container_->innerIdxToOuterIdx(this->cur_block, this->cur_pos) >= 0 &&
799 this->container_->innerIdxToOuterIdx(this->cur_block, this->cur_pos) < this->container_->size();
800 }
801
802 template <typename TYPE, typename ALLOC>
804 {
805 auto* other_it = dynamic_cast<const Iterator*>(other);
806 if (other_it == nullptr)
807 return false;
808 return this->operator-(*other_it) == -1;
809 }
810
811 template <typename TYPE, typename ALLOC>
813 {
814 auto* other_it = dynamic_cast<const Iterator*>(other);
815 if (other_it == nullptr)
816 return false;
817 return this->operator-(*other_it) == 1;
818 }
819
820 template <typename TYPE, typename ALLOC>
822 return "blocksList::Iterator";
823 }
824
825 template <typename TYPE, typename ALLOC>
827 : baseList<TYPE, ALLOC>(std::move(alloc)), map(), size_(), first_(), last_(), first_block(), last_block()
828 {
829 this->blocksListInit();
830 }
831
832 template <typename TYPE, typename ALLOC>
833 original::blocksList<TYPE, ALLOC>::blocksList(const std::initializer_list<TYPE>& lst) : blocksList() {
834 this->adjust(lst.size(), false);
835 for (const auto& e : lst) {
836 auto new_idx = innerIdxOffset(this->last_block, this->last_, 1);
837 this->last_block = new_idx.first();
838 this->last_ = new_idx.second();
839 this->setElem(this->last_block, this->last_, e);
840 this->size_ += 1;
841 }
842 }
843
844 template <typename TYPE, typename ALLOC>
846 this->adjust(arr.size(), false);
847 for (const auto& e : arr) {
848 auto new_idx = innerIdxOffset(this->last_block, this->last_, 1);
849 this->last_block = new_idx.first();
850 this->last_ = new_idx.second();
851 this->setElem(this->last_block, this->last_, e);
852 this->size_ += 1;
853 }
854 }
855
856 template <typename TYPE, typename ALLOC>
860
861 template <typename TYPE, typename ALLOC>
863 if (this == &other) return *this;
864
865 this->blocksListDestroy();
866 this->map = vector<TYPE*>{};
867
868 for (integer i = 0; i < other.map.size(); ++i) {
869 auto* block = this->blockArrayInit();
870 for (u_integer j = 0; j < BLOCK_MAX_SIZE; ++j) {
871 block[j] = other.getElem(i, j);
872 }
873 this->map.pushEnd(block);
874 }
875
876 this->first_ = other.first_;
877 this->last_ = other.last_;
878 this->size_ = other.size_;
879 this->first_block = other.first_block;
880 this->last_block = other.last_block;
881 if constexpr (ALLOC::propagate_on_container_copy_assignment::value){
882 this->allocator = other.allocator;
883 }
884 return *this;
885 }
886
887 template <typename TYPE, typename ALLOC>
889 {
890 this->operator=(std::move(other));
891 }
892
893 template <typename TYPE, typename ALLOC>
895 {
896 if (this == &other)
897 return *this;
898
899 this->blocksListDestroy();
900
901 this->map = std::move(other.map);
902 this->first_ = other.first_;
903 this->last_ = other.last_;
904 this->first_block = other.first_block;
905 this->last_block = other.last_block;
906 this->size_ = other.size_;
907 if constexpr (ALLOC::propagate_on_container_move_assignment::value){
908 this->allocator = std::move(other.allocator);
909 }
910 other.blocksListInit();
911 return *this;
912 }
913
914 template <typename TYPE, typename ALLOC>
916 {
917 if (this == &other)
918 return;
919
920 std::swap(this->map, other.map);
921 std::swap(this->size_, other.size_);
922 std::swap(this->first_, other.first_);
923 std::swap(this->last_, other.last_);
924 std::swap(this->first_block, other.first_block);
925 std::swap(this->last_block, other.last_block);
926 if constexpr (ALLOC::propagate_on_container_swap::value) {
927 std::swap(this->allocator, other.allocator);
928 }
929 }
930
931 template <typename TYPE, typename ALLOC>
933 if (this->indexOutOfBound(this->parseNegIndex(index))) throw outOfBoundError();
934 index = this->parseNegIndex(index);
935 auto inner_idx = this->outerIdxToInnerIdx(index);
936 return this->getElem(inner_idx.first(), inner_idx.second());
937 }
938
939 template <typename TYPE, typename ALLOC>
941 {
942 return this->size_;
943 }
944
945 template <typename TYPE, typename ALLOC>
947 return new Iterator(this->first_, this->first_block, &this->map.data(), this);
948 }
949
950 template <typename TYPE, typename ALLOC>
952 return new Iterator(this->last_, this->last_block, &this->map.data(), this);
953 }
954
955 template <typename TYPE, typename ALLOC>
957 if (this->indexOutOfBound(this->parseNegIndex(index))) throw outOfBoundError();
958 index = this->parseNegIndex(index);
959 auto inner_idx = this->outerIdxToInnerIdx(index);
960 return this->getElem(inner_idx.first(), inner_idx.second());
961 }
962
963 template <typename TYPE, typename ALLOC>
965 if (this->indexOutOfBound(index)) throw outOfBoundError();
966 index = this->parseNegIndex(index);
967 auto inner_idx = this->outerIdxToInnerIdx(index);
968 this->setElem(inner_idx.first(), inner_idx.second(), e);
969 }
970
971 template <typename TYPE, typename ALLOC>
973 for (u_integer i = 0; i < this->size(); ++i) {
974 if (auto idx = this->outerIdxToInnerIdx(i);
975 this->getElem(idx.first(), idx.second()) == e)
976 return i;
977 }
978 return this->size();
979 }
980
981 template <typename TYPE, typename ALLOC>
983 {
984 if (this->parseNegIndex(index) == this->size())
985 {
986 this->pushEnd(e);
987 } else if (this->parseNegIndex(index) == 0)
988 {
989 this->pushBegin(e);
990 } else{
991 if (this->indexOutOfBound(index))
992 throw outOfBoundError();
993
994 index = this->parseNegIndex(index);
995 const bool is_first = index <= (this->size() - 1) / 2;
996 this->adjust(1, is_first);
997 if (is_first){
998 this->moveElements(this->first_block, this->first_, index + 1, -1);
999 auto new_idx = innerIdxOffset(this->first_block, this->first_, -1);
1000 this->first_block = new_idx.first();
1001 this->first_ = new_idx.second();
1002 } else{
1003 auto idx = outerIdxToInnerIdx(index);
1004 this->moveElements(idx.first(), idx.second(), this->size() - index, 1);
1005 auto new_idx = innerIdxOffset(this->last_block, this->last_, 1);
1006 this->last_block = new_idx.first();
1007 this->last_ = new_idx.second();
1008 }
1009 this->size_ += 1;
1010 auto idx = outerIdxToInnerIdx(index);
1011 this->setElem(idx.first(), idx.second(), e);
1012 }
1013 }
1014
1015 template <typename TYPE, typename ALLOC>
1017 {
1018 if (this->parseNegIndex(index) == 0)
1019 return this->popBegin();
1020 if (this->parseNegIndex(index) == this->size() - 1)
1021 return this->popEnd();
1022 if (this->indexOutOfBound(index))
1023 throw outOfBoundError();
1024
1025 index = this->parseNegIndex(index);
1026 auto idx = outerIdxToInnerIdx(index);
1027 TYPE res = this->getElem(idx.first(), idx.second());
1028 if (index <= (this->size() - 1) / 2){
1029 moveElements(this->first_block, this->first_, index, 1);
1030 auto new_idx = innerIdxOffset(this->first_block, this->first_, 1);
1031 this->first_block = new_idx.first();
1032 this->first_ = new_idx.second();
1033 } else{
1034 auto idx_offset = innerIdxOffset(idx.first(), idx.second(), 1);
1035 moveElements(idx_offset.first(), idx_offset.second(), this->size() - 1 - index, -1);
1036 auto new_idx = innerIdxOffset(this->last_block, this->last_, -1);
1037 this->last_block = new_idx.first();
1038 this->last_ = new_idx.second();
1039 }
1040 this->size_ -= 1;
1041 return res;
1042 }
1043
1044 template <typename TYPE, typename ALLOC>
1046 {
1047 this->adjust(1, true);
1048 auto new_idx = innerIdxOffset(this->first_block, this->first_, -1);
1049 this->first_block = new_idx.first();
1050 this->first_ = new_idx.second();
1051 this->setElem(this->first_block, this->first_, e);
1052 this->size_ += 1;
1053 }
1054
1055 template <typename TYPE, typename ALLOC>
1057 {
1058 if (this->empty()) throw noElementError();
1059
1060 TYPE res = this->getElem(this->first_block, this->first_);
1061 auto new_idx = innerIdxOffset(this->first_block, this->first_, 1);
1062 this->first_block = new_idx.first();
1063 this->first_ = new_idx.second();
1064 this->size_ -= 1;
1065 return res;
1066 }
1067
1068 template <typename TYPE, typename ALLOC>
1070 {
1071 this->adjust(1, false);
1072 auto new_idx = innerIdxOffset(this->last_block, this->last_, 1);
1073 this->last_block = new_idx.first();
1074 this->last_ = new_idx.second();
1075 this->setElem(this->last_block, this->last_, e);
1076 this->size_ += 1;
1077 }
1078
1079 template <typename TYPE, typename ALLOC>
1081 {
1082 if (this->empty()) throw noElementError();
1083
1084 TYPE res = this->getElem(this->last_block, this->last_);
1085 auto new_idx = innerIdxOffset(this->last_block, this->last_, -1);
1086 this->last_block = new_idx.first();
1087 this->last_ = new_idx.second();
1088 this->size_ -= 1;
1089 return res;
1090 }
1091
1092 template <typename TYPE, typename ALLOC>
1094 return "blocksList";
1095 }
1096
1097 template <typename TYPE, typename ALLOC>
1099 this->blocksListDestroy();
1100 }
1101
1102 template <typename TYPE, typename ALLOC>
1104 {
1105 lhs.swap(rhs);
1106 }
1107
1108#endif //BLOCKSLIST_H
Provides a base class for variable-size serial containers.
Default memory allocator using allocators utilities.
Definition allocator.h:153
void swap(autoPtr &other) noexcept
Swaps the reference counters between two autoPtr instances.
Definition autoPtr.h:703
A base class for basic iterators.
Definition iterator.h:296
Base class for variable-size serial containers.
Definition baseList.h:43
Iterator for blocksList, supports forward and backward iteration.
Definition blocksList.h:192
Iterator * getNext() const override
Gets the next iterator.
Definition blocksList.h:766
Iterator * clone() const override
Clones the iterator.
Definition blocksList.h:694
void operator-=(integer steps) const override
Moves the iterator backward by the specified number of steps.
Definition blocksList.h:732
Iterator & operator=(const Iterator &other)
Assignment operator for the Iterator.
Definition blocksList.h:681
void prev() const override
Moves the iterator to the previous element.
Definition blocksList.h:718
bool hasNext() const override
Checks if there is a next element.
Definition blocksList.h:700
Iterator * getPrev() const override
Gets the previous iterator.
Definition blocksList.h:757
void next() const override
Moves the iterator to the next element.
Definition blocksList.h:712
bool hasPrev() const override
Checks if there is a previous element.
Definition blocksList.h:706
void operator+=(integer steps) const override
Advances the iterator by the specified number of steps.
Definition blocksList.h:724
void set(const TYPE &data) override
Sets the value of the element pointed to by the iterator.
Definition blocksList.h:789
TYPE & get() override
Gets the element pointed to by the iterator.
Definition blocksList.h:775
bool isValid() const override
Checks if the iterator is valid.
Definition blocksList.h:796
bool atPrev(const iterator< TYPE > *other) const override
Checks if the iterator is at the previous element relative to another iterator.
Definition blocksList.h:803
bool atNext(const iterator< TYPE > *other) const override
Checks if the iterator is at the next element relative to another iterator.
Definition blocksList.h:812
std::string className() const override
Gets the class name of the iterator.
Definition blocksList.h:821
A block-based list implementation.
Definition blocksList.h:30
std::string className() const override
Gets the class name of the blocksList.
Definition blocksList.h:1093
u_integer indexOf(const TYPE &e) const override
Finds the index of the first occurrence of the specified element.
Definition blocksList.h:972
void pushEnd(const TYPE &e) override
Pushes an element to the end of the blocksList.
Definition blocksList.h:1069
TYPE get(integer index) const override
Gets the element at the specified index.
Definition blocksList.h:932
blocksList(blocksList &&other) noexcept
Move constructor.
Definition blocksList.h:888
void pushBegin(const TYPE &e) override
Pushes an element to the beginning of the blocksList.
Definition blocksList.h:1045
void swap(blocksList &other) noexcept
Swaps the contents of this blocksList with another.
Definition blocksList.h:915
TYPE popEnd() override
Pops the element from the end of the blocksList.
Definition blocksList.h:1080
blocksList(ALLOC alloc=ALLOC{})
Constructs an empty blocksList.
Definition blocksList.h:826
u_integer size() const override
Gets the size of the blocksList.
Definition blocksList.h:940
Iterator * begins() const override
Gets an iterator to the beginning of the blocksList.
Definition blocksList.h:946
void set(integer index, const TYPE &e) override
Sets the element at the specified index.
Definition blocksList.h:964
blocksList(const array< TYPE > &arr)
Constructs a blocksList from an array.
Definition blocksList.h:845
TYPE popBegin() override
Pops the element from the beginning of the blocksList.
Definition blocksList.h:1056
void push(integer index, const TYPE &e) override
Pushes an element to the specified index in the blocksList.
Definition blocksList.h:982
blocksList & operator=(blocksList &&other) noexcept
Move assignment operator.
Definition blocksList.h:894
blocksList(const std::initializer_list< TYPE > &lst)
Constructs a blocksList from an initializer list.
Definition blocksList.h:833
TYPE pop(integer index) override
Pops the element at the specified index in the blocksList.
Definition blocksList.h:1016
blocksList(const blocksList &other)
Copy constructor.
Definition blocksList.h:857
Iterator * ends() const override
Gets an iterator to the end of the blocksList.
Definition blocksList.h:951
blocksList & operator=(const blocksList &other)
Copy assignment operator.
Definition blocksList.h:862
~blocksList() override
Destructor for the blocksList.
Definition blocksList.h:1098
TYPE & operator[](integer index) override
Gets a reference to the element at the specified index.
Definition blocksList.h:956
Abstract base class for containers.
Definition container.h:26
A stream class that allows iteration, comparison, hashing and printing.
Definition iterationStream.h:60
friend iterator< T > * operator-(const iterator< T > &it, integer steps)
Subtracts a number of steps from the iterator's current position and returns a new iterator.
Abstract base class for key-value mapping containers.
Definition map.h:49
Exception for missing element requests.
Definition error.h:298
Exception for container index out-of-range errors.
Definition error.h:192
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Abstract base class for unique element containers.
Definition set.h:44
Generic pair container implementation.
Main namespace for the project Original.
Definition algorithms.h:21
auto operator-(const iterator< T > &it, integer steps) -> iterator< T > *
Subtracts a number of steps from the iterator's current position and returns a new iterator.
Standard namespace extensions for original::alternative.
Definition allocator.h:351
void swap(original::objPoolAllocator< TYPE > &lhs, original::objPoolAllocator< TYPE > &rhs) noexcept
Specialization of std::swap for objPoolAllocator.
Definition allocator.h:635
Dynamic array container with automatic resizing.