31void Foam::CircularBuffer<T>::doReserve
37 if (storage_.size() < len)
40 const label newCapacity =
50 if (nocopy || empty())
55 storage_.resize_nocopy(newCapacity);
60 const labelRange range1 = range_one();
61 const labelRange range2 = range_two();
63 List<T> old(newCapacity);
68 for (
const label i : range1)
70 storage_[end_++] = std::move(old[i]);
72 for (
const label i : range2)
74 storage_[end_++] = std::move(old[i]);
86 const label len = size_one();
87 return (len ? storage_.slice(begin_, len) :
SubList<T>());
94 const label len = size_two();
95 return (len ? storage_.slice(0, len) :
SubList<T>());
102 const label len = size_one();
103 return (len ? storage_.slice(begin_, len) :
SubList<T>());
110 const label len = size_two();
111 return (len ? storage_.slice(0, len) :
SubList<T>());
118 if (
pos < 0)
return -1;
122 const auto list1 = this->array_one();
124 if (
pos < list1.size())
127 i = list1.find(val,
pos);
138 const auto list2 = this->array_two();
140 if (i < 0 && list2.size())
143 i = list2.find(val, pos);
159 const label
n = this->size();
160 const label nBy2 =
n/2;
162 for (label i = 0; i < nBy2; ++i)
172 const auto list1 = array_one();
173 const auto list2 = array_two();
175 List<T> result(list1.size() + list2.size());
179 result.slice(0, list1.size()) = list1;
183 result.slice(list1.size(), list1.size() + list2.size()) = list2;
void reverse()
Reverse the buffer order, swapping elements.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
label size() const noexcept
The current number of buffer items.
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!
SubList< T > array_one()
The contents of the first internal array.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A non-owning sub-view of a List (allocated or unallocated storage).
SubList< T > slice(const label pos, label len=-1)
Return SubList slice (non-const access) - no range checking.
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)