31 template<
class T,
int SizeMin>
32 template<
class ListType>
38 const label len = list.
size();
43 List<T>::setAddressableSize(capacity_);
44 List<T>::resize_nocopy(len);
45 capacity_ = List<T>::size();
49 List<T>::setAddressableSize(len);
50 List<T>::operator=(list);
54 template<
class T,
int SizeMin>
58 const label newCapacity
61 if (newCapacity == capacity_)
67 const label currLen =
min(List<T>::size(), newCapacity);
70 if (List<T>::size() == newCapacity)
72 List<T>::setAddressableSize(currLen+1);
77 List<T>::resize_nocopy(newCapacity);
84 capacity_ = List<T>::size();
85 List<T>::setAddressableSize(currLen);
89 template<
class T,
int SizeMin>
99 const label currLen = List<T>::size();
102 capacity_ =
max(SizeMin,
max(len, label(2*capacity_)));
106 List<T>::resize_nocopy(capacity_);
112 List<T>::setAddressableSize(currLen);
117 template<
class T,
int SizeMin>
124 this->doReserve(nocopy, len);
131 template<
class T,
int SizeMin>
139 template<
class T,
int SizeMin>
149 template<
class T,
int SizeMin>
157 capacity_(
Field<
T>::size())
161 template<
class T,
int SizeMin>
169 capacity_(
Field<
T>::size())
173 template<
class T,
int SizeMin>
184 template<
class T,
int SizeMin>
185 template<
int AnySizeMin>
192 capacity_(
Field<
T>::size())
196 template<
class T,
int SizeMin>
207 template<
class T,
int SizeMin>
215 capacity_(
Field<
T>::size())
219 template<
class T,
int SizeMin>
230 template<
class T,
int SizeMin>
231 template<
int AnySizeMin>
244 template<
class T,
int SizeMin>
257 template<
class T,
int SizeMin>
258 template<
int AnySizeMin>
271 template<
class T,
int SizeMin>
279 capacity_(
Field<
T>::size())
283 template<
class T,
int SizeMin>
292 capacity_(
Field<
T>::size())
296 template<
class T,
int SizeMin>
304 capacity_(
Field<
T>::size())
308 template<
class T,
int SizeMin>
312 capacity_(
Field<
T>::size())
316 template<
class T,
int SizeMin>
326 template<
class T,
int SizeMin>
327 inline std::streamsize
330 return std::streamsize(capacity_)*
sizeof(
T);
334 template<
class T,
int SizeMin>
340 this->doCapacity(
false, len);
344 template<
class T,
int SizeMin>
350 this->doCapacity(
true, len);
354 template<
class T,
int SizeMin>
364 template<
class T,
int SizeMin>
370 this->doReserve(
false, len);
374 template<
class T,
int SizeMin>
380 this->doReserve(
true, len);
384 template<
class T,
int SizeMin>
390 this->doResize(
false, len);
394 template<
class T,
int SizeMin>
400 this->doResize(
true, len);
404 template<
class T,
int SizeMin>
417 this->operator[](idx) = val;
423 template<
class T,
int SizeMin>
430 template<
class T,
int SizeMin>
438 template<
class T,
int SizeMin>
450 template<
class T,
int SizeMin>
455 if (currLen < capacity_)
466 template<
class T,
int SizeMin>
470 this->shrinkStorage();
475 template<
class T,
int SizeMin>
476 template<
int AnySizeMin>
484 static_cast<const List<T>*
>(
this)
485 ==
static_cast<const List<T>*
>(&other)
492 UList<T>::swap(other);
495 std::swap(this->capacity_, other.capacity_);
499 template<
class T,
int SizeMin>
500 template<
int AnySizeMin>
508 static_cast<const List<T>*
>(
this)
509 ==
static_cast<const List<T>*
>(&other)
516 UList<T>::swap(other);
519 const label oldCap = this->capacity();
520 const label newCap = other.
capacity();
522 this->setCapacity_unsafe(newCap);
527 template<
class T,
int SizeMin>
531 capacity_ = list.
size();
536 template<
class T,
int SizeMin>
537 template<
int AnySizeMin>
545 static_cast<const List<T>*
>(
this)
546 ==
static_cast<const List<T>*
>(&list)
561 template<
class T,
int SizeMin>
562 template<
int AnySizeMin>
570 static_cast<const List<T>*
>(
this)
571 ==
static_cast<const List<T>*
>(&list)
586 template<
class T,
int SizeMin>
587 template<
class... Args>
598 this->operator[](idx) =
T(std::forward<Args>(
args)...);
603 template<
class T,
int SizeMin>
612 this->operator[](idx) = val;
616 template<
class T,
int SizeMin>
625 this->operator[](idx) = std::move(val);
629 template<
class T,
int SizeMin>
638 <<
"Attempted push_back to self" 642 label idx = List<T>::size();
645 for (
const T& val : list)
647 this->operator[](idx++) = val;
652 template<
class T,
int SizeMin>
655 if (
n >= this->size())
668 template<
class T,
int SizeMin>
679 return this->operator[](i);
683 template<
class T,
int SizeMin>
693 template<
class T,
int SizeMin>
703 template<
class T,
int SizeMin>
709 doAssignDynList(list);
713 template<
class T,
int SizeMin>
724 doAssignDynList(list);
728 template<
class T,
int SizeMin>
742 doAssignDynList(list);
746 template<
class T,
int SizeMin>
756 template<
class T,
int SizeMin>
766 template<
class T,
int SizeMin>
767 template<
int AnySizeMin>
777 template<
class T,
int SizeMin>
778 template<
int AnySizeMin>
790 template<
class T,
int SizeMin>
809 template<
class T,
int SizeMin>
813 DynamicField<T, SizeMin>& rhs
816 return rhs.readList(is);
820 template<
class T,
int SizeMin>
824 const DynamicField<T, SizeMin>& rhs
827 os << static_cast<const Field<T>&>(rhs);
void size(const label n)
Older name for setAddressableSize.
void setCapacity(const label len)
Alter the size of the underlying storage.
void swap(DynamicField< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
patchWriters resize(patchIds.size())
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
DynamicField< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
void push_back(const T &val)
Copy append an element at the end of the list.
constexpr DynamicField() noexcept
Default construct, an empty field without allocation.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
void transfer(List< T > &list)
Transfer the parameter contents into this.
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
label capacity() const noexcept
Size of the underlying storage.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
tmp< DynamicField< T, SizeMin > > clone() const
Clone.
void setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
Abstract base class to hold the Field mapping addressing and weights.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Generic templated field type.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
OBJstream os(runTime.globalPath()/outputName)
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void shrinkStorage()
Shrink the allocated space to the number of elements used.
void clearStorage()
Clear the list and delete storage.
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.
void clearStorage()
Clear the list and delete storage.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
A class for managing temporary objects.
Foam::argList args(argc, argv)
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.
static constexpr const zero Zero
Global zero (0)