Go to the documentation of this file.
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);
125 List<T>::setAddressableSize(len);
131 template<
class T,
int SizeMin>
139 template<
class T,
int SizeMin>
149 template<
class T,
int SizeMin>
161 template<
class T,
int SizeMin>
173 template<
class T,
int SizeMin>
184 template<
class T,
int SizeMin>
185 template<
int AnySizeMin>
196 template<
class T,
int SizeMin>
207 template<
class T,
int SizeMin>
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>
283 template<
class T,
int SizeMin>
291 Field<T>(mapF, mapAddressing, weights),
296 template<
class T,
int SizeMin>
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>
490 if (this->cdata() == other.cdata())
499 std::swap(this->capacity_, other.capacity_);
503 template<
class T,
int SizeMin>
504 template<
int AnySizeMin>
510 auto&
self = (*this);
514 if (
self.cdata() == other.cdata())
523 const label oldCap =
self.capacity();
524 const label newCap = other.
capacity();
526 self.setCapacity_unsafe(newCap);
531 template<
class T,
int SizeMin>
535 capacity_ = list.size();
540 template<
class T,
int SizeMin>
541 template<
int AnySizeMin>
548 if (this->cdata() == list.cdata())
562 template<
class T,
int SizeMin>
563 template<
int AnySizeMin>
570 if (this->cdata() == list.cdata())
584 template<
class T,
int SizeMin>
594 this->operator[](idx) = val;
599 template<
class T,
int SizeMin>
609 this->operator[](idx) = std::move(val);
614 template<
class T,
int SizeMin>
624 <<
"Attempted appending to self"
631 for (
const T& val : list)
633 this->operator[](idx++) = val;
639 template<
class T,
int SizeMin>
661 template<
class T,
int SizeMin>
672 return this->operator[](i);
676 template<
class T,
int SizeMin>
686 template<
class T,
int SizeMin>
696 template<
class T,
int SizeMin>
706 template<
class T,
int SizeMin>
721 template<
class T,
int SizeMin>
731 template<
class T,
int SizeMin>
741 template<
class T,
int SizeMin>
742 template<
int AnySizeMin>
752 template<
class T,
int SizeMin>
753 template<
int AnySizeMin>
765 template<
class T,
int SizeMin>
784 template<
class T,
int SizeMin>
791 return rhs.readList(is);
795 template<
class T,
int SizeMin>
799 const DynamicField<T, SizeMin>& rhs
802 os << static_cast<const Field<T>&>(rhs);
void transfer(List< T > &list)
Transfer the parameter contents into this.
void setCapacity_unsafe(const label len) noexcept
void clearStorage()
Clear the list and delete storage.
void resize(const label len)
void setCapacity_nocopy(const label len)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
friend Ostream & operator(Ostream &os, const DynamicField< T, SizeMin > &rhs)
Write to Ostream.
label capacity() const noexcept
Size of the underlying storage.
Abstract base class to hold the Field mapping addressing and weights.
label capacity() const noexcept
Size of the underlying storage.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void swap(DynamicField< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
void shrinkStorage()
Shrink the allocated space to the number of elements used.
DynamicField< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void setCapacity(const label len)
Alter the size of the underlying storage.
patchWriters resize(patchIds.size())
Generic templated field type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr DynamicField() noexcept
Default construct, an empty field without allocation.
void reserve_nocopy(const label len)
OBJstream os(runTime.globalPath()/outputName)
errorManip< error > abort(error &err)
Istream & readList(Istream &is)
Read from Istream, discarding existing contents.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< DynamicField< T, SizeMin > > clone() const
Clone.
T remove()
Remove and return the top element.
void setCapacity_unsafe(const label len) noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void reserve(const label len)
void clearStorage()
Clear the list and delete storage.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
void resize_nocopy(const label len)
void size(const label n)
Older name for setAddressableSize.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
DynamicField< T, SizeMin > & append(const T &val)
Append an element at the end of the list.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.