23 #ifndef CIRCULAR_ARRAY_CC 24 #define CIRCULAR_ARRAY_CC 42 return this->capacity_;
53 return this->data_.
at(this->absoluteIndex(index));
58 return this->data_.
at(this->absoluteIndex(index));
63 return this->data_[this->absoluteIndex(index)];
68 return this->data_[this->absoluteIndex(index)];
74 return ((this->begin_ + index) % this->capacity_ + this->capacity_) % this->capacity_;
79 return this->data_[index];
84 return this->data_[index];
89 bool overflow = (this->begin_ + this->size_ > this->capacity_);
90 bool larger = (this->begin_ <= index);
91 bool smaller = (index <= (this->begin_ + this->size_ - 1) % this->capacity_);
92 return (!overflow && larger && smaller) || (overflow && (larger || smaller));
108 return (*
this)[this->size_ - 1];
113 return (*
this)[this->size_ - 1];
119 this->begin_ = this->absoluteIndex(indexes);
120 if (indexes > static_cast<ptrdiff_t>(this->size_))
122 else if (indexes < -static_cast<ptrdiff_t>(this->capacity_ - this->size_))
123 this->size_ = this->capacity_;
125 this->size_ -= indexes;
130 if (indexes > static_cast<ptrdiff_t>(this->capacity_ - this->size_)) {
131 this->begin_ = this->absoluteIndex(this->size_ + indexes);
132 this->size_ = this->capacity_;
133 }
else if (indexes < -static_cast<ptrdiff_t>(this->size_)) {
134 this->begin_ = this->absoluteIndex(this->size_ + indexes);
137 this->size_ += indexes;
149 this->capacity_ = capacity;
150 this->data_.resize(capacity);
156 this->capacity_ = capacity;
158 this->data_.resize(capacity, value);
165 this->data_.resize(this->capacity_, value);
170 #endif // CIRCULAR_ARRAY_CC A circular array container.
T & at(ptrdiff_t index)
Access specified element.