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)
87 template<
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_)),
164 return storage_.size();
171 return storage_.empty() || (begin_ == end_);
178 const label
diff(end_ - begin_);
182 return (storage_.size() +
diff);
192 return (storage_.size() - size());
239 storage_.swap(other.storage_);
240 std::swap(begin_, other.begin_);
241 std::swap(end_, other.end_);
248 this->doReserve(
false, len);
255 this->doReserve(
true, len);
262 return (this->array_one().contains(val) || this->array_two().contains(val));
269 return (this->
find(val,
pos) >= 0);
281 return storage_[begin_];
293 return storage_[begin_];
305 return storage_.rcValue(end_);
317 return storage_.rcValue(end_);
328 begin_ = storage_.rcIndex(begin_);
329 storage_[begin_] = val;
340 begin_ = storage_.rcIndex(begin_);
341 storage_[begin_] = std::move(val);
346 template<
class... Args>
353 begin_ = storage_.rcIndex(begin_);
354 storage_[begin_] =
T(std::forward<Args>(
args)...);
356 return storage_[begin_];
367 storage_[end_] = val;
368 end_ = storage_.fcIndex(end_);
379 storage_[end_] = std::move(val);
380 end_ = storage_.fcIndex(end_);
385 template<
class... Args>
392 const label backIndex = end_;
393 storage_[end_] =
T(std::forward<Args>(
args)...);
394 end_ = storage_.fcIndex(end_);
396 return storage_[backIndex];
411 begin_ = storage_.fcIndex(begin_);
428 end_ = storage_.rcIndex(end_);
437 if (this->contains(val))
443 this->push_back(val);
452 const label len = rhs.size();
460 for (label i = 0; i < len; ++i)
462 storage_[end_] = rhs[i];
463 end_ = storage_.fcIndex(end_);
473 const IndirectListBase<T, Addr>& rhs
476 const label len = rhs.size();
484 for (label i = 0; i < len; ++i)
486 storage_[end_] = rhs[i];
487 end_ = storage_.fcIndex(end_);
498 const label idx = this->toGlobal(i);
499 return storage_[idx];
506 const label idx = this->toGlobal(i);
507 return storage_[idx];
523 const label len = (list1.size() + list2.size());
533 for (
const T& val : list1)
535 storage_[end_] = val;
539 for (
const T& val : list2)
541 storage_[end_] = val;
556 this->clearStorage();
564 this->array_one() = val;
565 this->array_two() = val;
585 template<
class AnyAddr>
void swap(CircularBuffer< T > &other)
Swap content, independent of sizing parameter.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void pop_front(label n=1)
Shrink by moving the front of the buffer 1 or more times.
constexpr CircularBuffer() noexcept
Default construct, empty buffer without allocation.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelRange range_two() const noexcept
The addressing range covered by array_two()
A range or interval of labels defined by a start and a size.
void clear() noexcept
Clear the addressed buffer, does not change allocation.
void push_front(const T &val)
Copy prepend an element to the front of the buffer.
label size() const noexcept
The current number of buffer items.
T & back()
Access the last element (back). Requires !empty().
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
bool empty() const noexcept
Empty or exhausted buffer.
T & emplace_front(Args &&... args)
Construct an element at the front of the buffer, return reference to the new element.
void clearStorage()
Clear the buffer and delete storage.
T & operator[](const label i)
Non-const access to an element in the list.
dimensionedScalar pos(const dimensionedScalar &ds)
List< T > list() const
Return a copy of the buffer flattened into a single List. Use sparingly!
A simple list of objects of type <T> that is intended to be used as a circular buffer (eg...
void pop_back(label n=1)
Shrink by moving the end of the buffer 1 or more times.
labelRange range_one() const noexcept
The addressing range covered by array_one()
T & emplace_back(Args &&... args)
Construct an element at the end of the buffer, return reference to the new element.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & front()
Access the first element (front). Requires !empty().
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool contains(const T &val) const
True if the value is contained in the list.
label space() const noexcept
The nominal space available to fill. Subtract 1 for the number to append before re-balancing is neede...
SubList< T > array_one()
The contents of the first internal array.
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
void operator=(const CircularBuffer< T > &list)
Copy construct.
triangles reserve(surf.size())
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void push_back(const T &val)
Copy append an element to the end of the buffer.
Foam::argList args(argc, argv)
label capacity() const noexcept
Size of the underlying storage.
SubList< T > array_two()
The contents of the second internal array.
label push_uniq(const T &val)
Append an element if not already in the buffer.
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...