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 =
Foam::min(List<T>::size(), newCapacity);
69 List<T>::setAddressableSize(capacity_);
72 List<T>::resize_nocopy(newCapacity);
76 List<T>::resize_copy(currLen, newCapacity);
79 capacity_ = List<T>::size();
80 List<T>::setAddressableSize(currLen);
84 template<
class T,
int SizeMin>
94 const label currLen = List<T>::size();
98 Foam::ListPolicy::reserve_size<SizeMin, 2>(len, capacity_);
102 List<T>::resize_nocopy(capacity_);
108 List<T>::setAddressableSize(currLen);
113 template<
class T,
int SizeMin>
120 this->doReserve(nocopy, len);
127 template<
class T,
int SizeMin>
135 template<
class T,
int SizeMin>
141 reserve_nocopy(initialCapacity);
145 template<
class T,
int SizeMin>
148 const std::pair<label,label>& sizing
152 capacity_(
Field<
T>::size())
158 template<
class T,
int SizeMin>
166 capacity_(
Field<
T>::size())
170 template<
class T,
int SizeMin>
182 template<
class T,
int SizeMin>
185 const DynamicField<T, SizeMin>& list
193 template<
class T,
int SizeMin>
194 template<
int AnySizeMin>
201 capacity_(
Field<
T>::size())
205 template<
class T,
int SizeMin>
216 template<
class T,
int SizeMin>
224 capacity_(
Field<
T>::size())
228 template<
class T,
int SizeMin>
239 template<
class T,
int SizeMin>
240 template<
int AnySizeMin>
249 content.setCapacity_unsafe(0);
253 template<
class T,
int SizeMin>
262 content.setCapacity_unsafe(0);
266 template<
class T,
int SizeMin>
267 template<
int AnySizeMin>
276 content.setCapacity_unsafe(0);
280 template<
class T,
int SizeMin>
281 template<
int AnySizeMin>
300 capacity_ = content.
size();
305 template<
class T,
int SizeMin>
306 template<
int AnySizeMin>
309 DynamicList<T, AnySizeMin>& content,
319 capacity_ = content.capacity();
320 content.setCapacity_unsafe(0);
325 capacity_ = content.size();
330 template<
class T,
int SizeMin>
338 capacity_(content.size())
351 template<
class T,
int SizeMin>
354 const UList<T>& mapF,
359 capacity_(
Field<
T>::size())
363 template<
class T,
int SizeMin>
372 capacity_(
Field<
T>::size())
376 template<
class T,
int SizeMin>
384 capacity_(
Field<
T>::size())
388 template<
class T,
int SizeMin>
392 capacity_(
Field<
T>::size())
396 template<
class T,
int SizeMin>
406 template<
class T,
int SizeMin>
407 inline std::streamsize
410 return std::streamsize(capacity_)*
sizeof(
T);
414 template<
class T,
int SizeMin>
420 this->doCapacity(
false, len);
424 template<
class T,
int SizeMin>
430 this->doCapacity(
true, len);
434 template<
class T,
int SizeMin>
440 this->doReserve(
false, len);
444 template<
class T,
int SizeMin>
450 this->doReserve(
true, len);
454 template<
class T,
int SizeMin>
472 template<
class T,
int SizeMin>
478 this->doResize(
false, len);
482 template<
class T,
int SizeMin>
488 this->doResize(
true, len);
492 template<
class T,
int SizeMin>
499 this->doResize(
true, len);
504 template<
class T,
int SizeMin>
519 this->begin(oldLen), this->
end(), val
525 template<
class T,
int SizeMin>
532 template<
class T,
int SizeMin>
540 template<
class T,
int SizeMin>
545 if (currLen < capacity_)
554 template<
class T,
int SizeMin>
557 if (List<T>::empty())
566 template<
class T,
int SizeMin>
572 static_cast<const List<T>*
>(
this)
573 ==
static_cast<const List<T>*
>(&list)
580 this->shrink_to_fit();
583 UList<T>::swap(list);
590 template<
class T,
int SizeMin>
591 template<
int AnySizeMin>
599 static_cast<const List<T>*
>(
this)
600 ==
static_cast<const List<T>*
>(&other)
607 UList<T>::swap(other);
610 std::swap(this->capacity_, other.capacity_);
614 template<
class T,
int SizeMin>
615 template<
int AnySizeMin>
623 static_cast<const List<T>*
>(
this)
624 ==
static_cast<const List<T>*
>(&other)
631 UList<T>::swap(other);
634 const label oldCap = this->capacity();
635 const label newCap = other.
capacity();
637 this->setCapacity_unsafe(newCap);
642 template<
class T,
int SizeMin>
650 template<
class T,
int SizeMin>
651 template<
int AnySizeMin>
659 static_cast<const List<T>*
>(
this)
660 ==
static_cast<const List<T>*
>(&list)
673 template<
class T,
int SizeMin>
674 template<
int AnySizeMin>
682 static_cast<const List<T>*
>(
this)
683 ==
static_cast<const List<T>*
>(&list)
696 template<
class T,
int SizeMin>
697 template<
class... Args>
708 this->operator[](idx) =
T(std::forward<Args>(
args)...);
709 return this->operator[](idx);
713 template<
class T,
int SizeMin>
722 this->operator[](idx) = val;
726 template<
class T,
int SizeMin>
735 this->operator[](idx) = std::move(val);
739 template<
class T,
int SizeMin>
748 <<
"Attempted push_back to self" 752 const label idx = List<T>::size();
755 std::copy(list.
begin(), list.
end(), this->begin(idx));
759 template<
class T,
int SizeMin>
768 <<
"Attempted push_back to self" 772 const label idx = List<T>::size();
775 std::move(list.
begin(), list.
end(), this->begin(idx));
781 template<
class T,
int SizeMin>
784 if (
n >= this->size())
797 template<
class T,
int SizeMin>
808 return this->operator[](i);
812 template<
class T,
int SizeMin>
822 template<
class T,
int SizeMin>
832 template<
class T,
int SizeMin>
838 doAssignDynList(list);
842 template<
class T,
int SizeMin>
853 doAssignDynList(list);
857 template<
class T,
int SizeMin>
871 doAssignDynList(list);
875 template<
class T,
int SizeMin>
885 template<
class T,
int SizeMin>
895 template<
class T,
int SizeMin>
896 template<
int AnySizeMin>
906 template<
class T,
int SizeMin>
907 template<
int AnySizeMin>
919 template<
class T,
int SizeMin>
938 template<
class T,
int SizeMin>
942 DynamicField<T, SizeMin>& rhs
945 return rhs.readList(is);
949 template<
class T,
int SizeMin>
953 const DynamicField<T, SizeMin>& rhs
956 os << static_cast<const Field<T>&>(rhs);
void size(const label n)
Older name for setAddressableSize.
void swap(List< T > &list)
Swap with plain List content. Implies shrink_to_fit().
void setCapacity(const label len)
Alter the size of the underlying storage.
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)...
void reserve_exact(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
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 to 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.
UList< label > labelUList
A UList of labels.
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...
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...
label capacity() const noexcept
Size of the underlying storage.
Generic templated field type.
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a 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)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
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...
void shrink_unsafe()
Shrink the internal bookkeeping of the allocated space to the number of addressed elements without af...
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 resize_fill(const label len, const T &val)
Alter addressable size and set val for all addressed entries.
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)
void operator=(const Field< T > &)
Copy assignment.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
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 ...
iterator end() noexcept
Return an iterator to end traversing the UList.
A class for managing temporary objects.
Foam::argList args(argc, argv)
A non-counting (dummy) refCount.
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.