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>
145 reserve_nocopy(initialCapacity);
149 template<
class T,
int SizeMin>
157 capacity_(
Field<
T>::size())
161 template<
class T,
int SizeMin>
173 template<
class T,
int SizeMin>
176 const DynamicField<T, SizeMin>& list
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>
238 capacity_(content.capacity())
240 content.setCapacity_unsafe(0);
244 template<
class T,
int SizeMin>
251 capacity_(content.capacity())
253 content.setCapacity_unsafe(0);
257 template<
class T,
int SizeMin>
258 template<
int AnySizeMin>
265 capacity_(content.capacity())
267 content.setCapacity_unsafe(0);
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>
425 template<
class T,
int SizeMin>
432 template<
class T,
int SizeMin>
440 template<
class T,
int SizeMin>
445 if (currLen < capacity_)
455 template<
class T,
int SizeMin>
458 if (List<T>::empty())
467 template<
class T,
int SizeMin>
471 this->shrink_to_fit();
476 template<
class T,
int SizeMin>
482 static_cast<const List<T>*
>(
this)
483 ==
static_cast<const List<T>*
>(&list)
490 this->shrink_to_fit();
493 UList<T>::swap(list);
500 template<
class T,
int SizeMin>
501 template<
int AnySizeMin>
509 static_cast<const List<T>*
>(
this)
510 ==
static_cast<const List<T>*
>(&other)
517 UList<T>::swap(other);
520 std::swap(this->capacity_, other.capacity_);
524 template<
class T,
int SizeMin>
525 template<
int AnySizeMin>
533 static_cast<const List<T>*
>(
this)
534 ==
static_cast<const List<T>*
>(&other)
541 UList<T>::swap(other);
544 const label oldCap = this->capacity();
545 const label newCap = other.
capacity();
547 this->setCapacity_unsafe(newCap);
552 template<
class T,
int SizeMin>
560 template<
class T,
int SizeMin>
561 template<
int AnySizeMin>
569 static_cast<const List<T>*
>(
this)
570 ==
static_cast<const List<T>*
>(&list)
583 template<
class T,
int SizeMin>
584 template<
int AnySizeMin>
592 static_cast<const List<T>*
>(
this)
593 ==
static_cast<const List<T>*
>(&list)
606 template<
class T,
int SizeMin>
607 template<
class... Args>
618 this->operator[](idx) =
T(std::forward<Args>(
args)...);
619 return this->operator[](idx);
623 template<
class T,
int SizeMin>
632 this->operator[](idx) = val;
636 template<
class T,
int SizeMin>
645 this->operator[](idx) = std::move(val);
649 template<
class T,
int SizeMin>
658 <<
"Attempted push_back to self" 662 const label idx = List<T>::size();
669 template<
class T,
int SizeMin>
678 <<
"Attempted push_back to self" 682 const label idx = List<T>::size();
691 template<
class T,
int SizeMin>
694 if (
n >= this->size())
707 template<
class T,
int SizeMin>
718 return this->operator[](i);
722 template<
class T,
int SizeMin>
732 template<
class T,
int SizeMin>
742 template<
class T,
int SizeMin>
748 doAssignDynList(list);
752 template<
class T,
int SizeMin>
763 doAssignDynList(list);
767 template<
class T,
int SizeMin>
781 doAssignDynList(list);
785 template<
class T,
int SizeMin>
795 template<
class T,
int SizeMin>
805 template<
class T,
int SizeMin>
806 template<
int AnySizeMin>
816 template<
class T,
int SizeMin>
817 template<
int AnySizeMin>
829 template<
class T,
int SizeMin>
848 template<
class T,
int SizeMin>
852 DynamicField<T, SizeMin>& rhs
855 return rhs.readList(is);
859 template<
class T,
int SizeMin>
863 const DynamicField<T, SizeMin>& rhs
866 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)...
DynamicField< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicField.
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 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...
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.
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 setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
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 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)
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
A non-counting (dummy) refCount.
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.