31template<
class T,
int SizeMin>
32template<
class ListType>
33inline void Foam::DynamicField<T, SizeMin>::doAssignDynList
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);
54template<
class T,
int SizeMin>
55inline void Foam::DynamicField<T, SizeMin>::doCapacity_copy
58 const label newCapacity
61 if (newCapacity == capacity_)
67 const label currLen = std::min(List<T>::size(), newCapacity);
70 count = std::min(count, currLen);
73 List<T>::setAddressableSize(capacity_);
77 List<T>::resize_copy(count, newCapacity);
81 List<T>::resize_nocopy(newCapacity);
84 capacity_ = List<T>::size();
85 List<T>::setAddressableSize(currLen);
89template<
class T,
int SizeMin>
90inline void Foam::DynamicField<T, SizeMin>::doReserve_copy
99 const label currLen = List<T>::size();
102 count = std::min(count, currLen);
120 capacity_ = List<T>::size();
121 List<T>::setAddressableSize(currLen);
128template<
class T,
int SizeMin>
136template<
class T,
int SizeMin>
146template<
class T,
int SizeMin>
149 std::pair<label,label> sizing
152 Field<
T>(std::
max(sizing.first, sizing.second)),
159template<
class T,
int SizeMin>
171template<
class T,
int SizeMin>
183template<
class T,
int SizeMin>
194template<
class T,
int SizeMin>
195template<
int AnySizeMin>
206template<
class T,
int SizeMin>
217template<
class T,
int SizeMin>
229template<
class T,
int SizeMin>
240template<
class T,
int SizeMin>
241template<
int AnySizeMin>
250 content.setCapacity_unsafe(0);
254template<
class T,
int SizeMin>
263 content.setCapacity_unsafe(0);
267template<
class T,
int SizeMin>
268template<
int AnySizeMin>
277 content.setCapacity_unsafe(0);
281template<
class T,
int SizeMin>
282template<
int AnySizeMin>
306template<
class T,
int SizeMin>
307template<
int AnySizeMin>
331template<
class T,
int SizeMin>
353template<
class T,
int SizeMin>
360 Field<
T>(mapF, mapAddressing),
365template<
class T,
int SizeMin>
373 Field<
T>(mapF, mapAddressing, weights),
378template<
class T,
int SizeMin>
390template<
class T,
int SizeMin>
398template<
class T,
int SizeMin>
408template<
class T,
int SizeMin>
409inline std::streamsize
412 return std::streamsize(capacity_)*
sizeof(
T);
416template<
class T,
int SizeMin>
427template<
class T,
int SizeMin>
434 doCapacity_copy(0, len);
438template<
class T,
int SizeMin>
449template<
class T,
int SizeMin>
456 doReserve_copy(0, len);
460template<
class T,
int SizeMin>
488template<
class T,
int SizeMin>
499template<
class T,
int SizeMin>
507 doReserve_copy(count, len);
512template<
class T,
int SizeMin>
524template<
class T,
int SizeMin>
535template<
class T,
int SizeMin>
558template<
class T,
int SizeMin>
565template<
class T,
int SizeMin>
578template<
class T,
int SizeMin>
582 if (currLen < capacity_)
591template<
class T,
int SizeMin>
599 static_cast<const List<T>*
>(
this)
600 ==
static_cast<const List<T>*
>(&other)
608 this->shrink_to_fit();
618template<
class T,
int SizeMin>
619template<
int AnySizeMin>
629 static_cast<const List<T>*
>(
this)
630 ==
static_cast<const List<T>*
>(&other)
641 std::swap(this->capacity_, other.capacity_);
645template<
class T,
int SizeMin>
646template<
int AnySizeMin>
656 static_cast<const List<T>*
>(
this)
657 ==
static_cast<const List<T>*
>(&other)
668 auto old = capacity_;
670 other.setCapacity_unsafe(old);
674template<
class T,
int SizeMin>
686template<
class T,
int SizeMin>
687template<
int AnySizeMin>
698 ==
static_cast<const UList<T>*
>(&other)
706 this->clearStorage();
717template<
class T,
int SizeMin>
718template<
int AnySizeMin>
729 ==
static_cast<const UList<T>*
>(&other)
737 this->clearStorage();
748template<
class T,
int SizeMin>
749template<
class... Args>
765template<
class T,
int SizeMin>
778template<
class T,
int SizeMin>
791template<
class T,
int SizeMin>
802 ==
static_cast<const UList<T>*
>(&list)
807 <<
"Attempted push_back to self"
818template<
class T,
int SizeMin>
829 ==
static_cast<const UList<T>*
>(&list)
834 <<
"Attempted push_back to self"
848template<
class T,
int SizeMin>
851 if (
n >= this->size())
864template<
class T,
int SizeMin>
870 if (i >= List<T>::size())
875 return this->operator[](i);
879template<
class T,
int SizeMin>
889template<
class T,
int SizeMin>
899template<
class T,
int SizeMin>
905 doAssignDynList(list);
909template<
class T,
int SizeMin>
920 doAssignDynList(list);
924template<
class T,
int SizeMin>
938 doAssignDynList(list);
942template<
class T,
int SizeMin>
952template<
class T,
int SizeMin>
962template<
class T,
int SizeMin>
963template<
int AnySizeMin>
973template<
class T,
int SizeMin>
974template<
int AnySizeMin>
986template<
class T,
int SizeMin>
1005template<
class T,
int SizeMin>
1009 DynamicField<T, SizeMin>&
rhs
1012 return rhs.readList(is);
1016template<
class T,
int SizeMin>
1017inline Foam::Ostream& Foam::operator<<
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void transfer(List< T > &list)
Transfer the parameter contents into this.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void setCapacity_unsafe(label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
void reserve_exact(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.
void resize_copy(label count, const label len)
Alter addressable size, retaining the first count contents.
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
void swap(List< T > &other)
Swap with plain List content. Implies shrink_to_fit().
void clearStorage()
Clear the list and delete storage.
tmp< DynamicField< T, SizeMin > > clone() const
Clone.
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.
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.
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
void resize_fill(const label len, const T &val)
Alter addressable size and set val for all addressed entries.
void setCapacity(const label len)
Alter the size of the underlying storage.
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void setCapacity_unsafe(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.
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
Abstract base class to hold the Field mapping addressing and weights.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
tmp< Field< T > > T() const
void operator=(const Field< Type > &)
Copy assignment.
constexpr Field() noexcept
void map(const UList< T > &mapF, const labelUList &mapAddressing)
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< Type > &list)
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void resize_copy(label count, const label len)
Change allocated size of list, retaining the first count elements.
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
iterator end() noexcept
Return an iterator to end traversing the UList.
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
label capacity() const noexcept
Size of the underlying storage.
label size() const noexcept
The number of elements in the container.
void size(const label n)
Older name for setAddressableSize.
void setAddressableSize(const label n) noexcept
Set addressed size to be inconsistent with allocated storage.
T & operator[](const label i)
Return element of UList.
UList< T > & operator=(const UList< T > &)=delete
No copy assignment (default: shallow copy).
A class for managing temporary objects.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
IntType reserve_size(IntType requested, IntType capacity) noexcept
Calculate a reserve size (eg, doubling) based on the requested length and the current capacity.
List< scalarList > scalarListList
List of scalarList.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
List< labelList > labelListList
List of labelList.
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)
#define FOAM_UNLIKELY(cond)
A non-counting (dummy) refCount.