31inline Foam::label Foam::CircularBuffer<T>::toGlobal(label i)
const
33 const label len = this->size();
43 while (i < 0) i += len;
48 while (i >= len) i -= len;
53 if (i >= storage_.size())
63inline Foam::label Foam::CircularBuffer<T>::size_one() const noexcept
69 : (storage_.size() - begin_)
75inline Foam::label Foam::CircularBuffer<T>::size_two() const noexcept
79 (end_ && end_ < begin_)
81 :
static_cast<label
>(0)
87template<
class OtherListType>
88inline void Foam::CircularBuffer<T>::copyList(
const OtherListType& rhs)
92 const label len =
rhs.size();
102 for (label i = 0; i < len; ++i)
104 storage_[end_] =
rhs[i];
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);
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);
346template<
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_);
385template<
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))
452 const label len =
rhs.size();
460 for (label i = 0; i < len; ++i)
462 storage_[end_] =
rhs[i];
463 end_ = storage_.fcIndex(end_);
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];
521 const auto list1 =
rhs.array_one();
522 const auto list2 =
rhs.array_two();
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;
585template<
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 & emplace_front(Args &&... args)
Construct an element at the front of the buffer, return reference to the new element.
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.
T & emplace_back(Args &&... args)
Construct an element at the end of the buffer, return reference to the new element.
bool empty() const noexcept
Empty or exhausted buffer.
bool contains(const T &val) const
True if the value is contained in the list.
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
T & back()
Access the last element (back). Requires !empty().
void clearStorage()
Clear the buffer and delete storage.
label push_uniq(const T &val)
Append an element if not already in the buffer.
label capacity() const noexcept
Size of the underlying storage.
label find(const writeData *&val, label pos=0) const
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.
T & front()
Access the first element (front). Requires !empty().
static constexpr label min_size() noexcept
Lower capacity limit.
SubList< T > array_two()
The contents of the second internal array.
List< T > list() const
Return a copy of the buffer flattened into a single List. Use sparingly!
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
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
The nominal space available to fill. Subtract 1 for the number to append before re-balancing is neede...
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.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A range or interval of labels defined by a start and a size.
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.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
triangles reserve(surf.size())
Foam::argList args(argc, argv)