33 const label len = this->size();
43 while (i < 0) i += len;
48 while (i >= len) i -= len;
53 if (i >= storage_.size())
69 : (storage_.size() - begin_)
79 (end_ && end_ < begin_)
81 :
static_cast<label
>(0)
87template<
class OtherListType>
92 const label len = rhs.size();
102 for (label i = 0; i < len; ++i)
104 storage_[end_] = rhs[i];
125 storage_(
max(min_size(), len + 1)),
137 storage_(list.storage_),
149 storage_(std::move(list.storage_)),
163 return storage_.size();
170 return storage_.empty() || (begin_ == end_);
177 const label
diff(end_ - begin_);
181 return (storage_.size() +
diff);
191 return (storage_.size() - size());
238 storage_.swap(other.storage_);
239 std::swap(begin_, other.begin_);
240 std::swap(end_, other.end_);
247 this->doReserve(
false, len);
254 this->doReserve(
true, len);
261 return (this->find(val,
pos) >= 0);
273 return storage_[begin_];
285 return storage_[begin_];
297 return storage_.rcValue(end_);
309 return storage_.rcValue(end_);
320 begin_ = storage_.rcIndex(begin_);
321 storage_[begin_] = val;
332 begin_ = storage_.rcIndex(begin_);
333 storage_[begin_] = std::move(val);
344 storage_[end_] = val;
345 end_ = storage_.fcIndex(end_);
356 storage_[end_] = std::move(val);
357 end_ = storage_.fcIndex(end_);
372 begin_ = storage_.fcIndex(begin_);
389 end_ = storage_.rcIndex(end_);
398 if (this->
found(val))
404 this->push_back(val);
413 const label len = rhs.
size();
417 reserve(size() + len + 1);
421 for (label i = 0; i < len; ++i)
423 storage_[end_] = rhs[i];
437 const label len = rhs.
size();
441 reserve(size() + len + 1);
445 for (label i = 0; i < len; ++i)
447 storage_[end_] = rhs[i];
459 const label idx = this->toGlobal(i);
460 return storage_[idx];
467 const label idx = this->toGlobal(i);
468 return storage_[idx];
484 const label len = (list1.size() + list2.size());
494 for (
const T& val : list1)
496 storage_[end_] = val;
500 for (
const T& val : list2)
502 storage_[end_] = val;
517 this->clearStorage();
525 this->array_one() = val;
526 this->array_two() = val;
533 this->array_one() =
Zero;
534 this->array_two() =
Zero;
546template<
class AnyAddr>
A simple list of objects of type <T> that is intended to be used as a circular buffer (eg,...
void pop_front(label n=1)
Shrink by moving the front of the buffer 1 or more times.
void clear() noexcept
Clear the addressed buffer, does not change allocation.
labelRange range_one() const noexcept
The addressing range covered by array_one()
T & first()
Access the first element (front). Requires !empty().
void pop_back(label n=1)
Shrink by moving the end of the buffer 1 or more times.
constexpr CircularBuffer() noexcept
Default construct, empty buffer without allocation.
bool empty() const noexcept
Empty or exhausted buffer.
void reserve_nocopy(const label len)
void clearStorage()
Clear the buffer and delete storage.
label appendUniq(const T &val)
Append an element if not already in the buffer.
label capacity() const noexcept
Size of the underlying storage.
label size() const noexcept
The current number of buffer items.
void push_back(const T &val)
Copy append an element to the end of the buffer.
SubList< T > array_two()
The contents of the first internal array.
void reserve(const label len)
labelRange range_two() const noexcept
The addressing range covered by array_two()
void swap(CircularBuffer< T > &other)
Swap content, independent of sizing parameter.
label space() const noexcept
void push_front(const T &val)
Copy prepend an element to the front of the buffer.
void operator=(const CircularBuffer< T > &list)
Copy construct.
SubList< T > array_one()
The contents of the first internal array.
T & operator[](const label i)
Non-const access to an element in the list.
T & last()
Access the last element (back). Requires !empty().
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
label fcIndex(const label i) const
label size() const noexcept
The number of elements in the list.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
A range or interval of labels defined by a start and a size.
bool append() const noexcept
True if output format uses an append mode.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar pos(const dimensionedScalar &ds)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)