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>
333 template<
class T,
int SizeMin>
334 inline std::streamsize
337 return std::streamsize(capacity_)*
sizeof(
T);
341 template<
class T,
int SizeMin>
347 this->doCapacity(
false, len);
351 template<
class T,
int SizeMin>
357 this->doCapacity(
true, len);
361 template<
class T,
int SizeMin>
371 template<
class T,
int SizeMin>
377 this->doReserve(
false, len);
381 template<
class T,
int SizeMin>
387 this->doReserve(
true, len);
391 template<
class T,
int SizeMin>
397 this->doResize(
false, len);
401 template<
class T,
int SizeMin>
407 this->doResize(
true, len);
411 template<
class T,
int SizeMin>
424 this->operator[](idx) = val;
430 template<
class T,
int SizeMin>
437 template<
class T,
int SizeMin>
445 template<
class T,
int SizeMin>
457 template<
class T,
int SizeMin>
462 if (currLen < capacity_)
473 template<
class T,
int SizeMin>
477 this->shrinkStorage();
482 template<
class T,
int SizeMin>
483 template<
int AnySizeMin>
491 static_cast<const List<T>*
>(
this)
492 ==
static_cast<const List<T>*
>(&other)
499 UList<T>::swap(other);
502 std::swap(this->capacity_, other.capacity_);
506 template<
class T,
int SizeMin>
507 template<
int AnySizeMin>
515 static_cast<const List<T>*
>(
this)
516 ==
static_cast<const List<T>*
>(&other)
523 UList<T>::swap(other);
526 const label oldCap = this->capacity();
527 const label newCap = other.
capacity();
529 this->setCapacity_unsafe(newCap);
534 template<
class T,
int SizeMin>
538 capacity_ = list.
size();
543 template<
class T,
int SizeMin>
544 template<
int AnySizeMin>
552 static_cast<const List<T>*
>(
this)
553 ==
static_cast<const List<T>*
>(&list)
568 template<
class T,
int SizeMin>
569 template<
int AnySizeMin>
577 static_cast<const List<T>*
>(
this)
578 ==
static_cast<const List<T>*
>(&list)
593 template<
class T,
int SizeMin>
602 this->operator[](idx) = val;
606 template<
class T,
int SizeMin>
615 this->operator[](idx) = std::move(val);
619 template<
class T,
int SizeMin>
628 <<
"Attempted push_back to self" 632 label idx = List<T>::size();
635 for (
const T& val : list)
637 this->operator[](idx++) = val;
642 template<
class T,
int SizeMin>
645 if (
n >= this->size())
656 template<
class T,
int SizeMin>
660 const label idx = List<T>::size() - 1;
668 const T& val = List<T>::operator[](idx);
670 List<T>::setAddressableSize(idx);
678 template<
class T,
int SizeMin>
689 return this->operator[](i);
693 template<
class T,
int SizeMin>
703 template<
class T,
int SizeMin>
713 template<
class T,
int SizeMin>
723 template<
class T,
int SizeMin>
738 template<
class T,
int SizeMin>
748 template<
class T,
int SizeMin>
758 template<
class T,
int SizeMin>
759 template<
int AnySizeMin>
769 template<
class T,
int SizeMin>
770 template<
int AnySizeMin>
782 template<
class T,
int SizeMin>
801 template<
class T,
int SizeMin>
805 DynamicField<T, SizeMin>& rhs
808 return rhs.readList(is);
812 template<
class T,
int SizeMin>
816 const DynamicField<T, SizeMin>& rhs
819 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.
void push_back(const T &val)
Append an element at the end of the list.
constexpr DynamicField() noexcept
Default construct, an empty field without allocation.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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...
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...
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)
label capacity() const noexcept
Size of the underlying storage.
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.
T remove()
Remove and return the last element. Fatal on an empty list.
label capacity() const noexcept
Size of the underlying storage.
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.
static constexpr const zero Zero
Global zero (0)