Go to the documentation of this file.
33 template<
class T,
int SizeMin>
34 template<
class ListType>
40 const label len = list.size();
45 List<T>::setAddressableSize(capacity_);
46 List<T>::resize_nocopy(len);
47 capacity_ = List<T>::size();
51 List<T>::setAddressableSize(len);
52 List<T>::operator=(list);
56 template<
class T,
int SizeMin>
60 const label newCapacity
63 if (newCapacity == capacity_)
69 const label currLen =
min(List<T>::size(), newCapacity);
72 if (List<T>::size() == newCapacity)
78 List<T>::setAddressableSize(currLen+1);
83 List<T>::resize_nocopy(newCapacity);
90 capacity_ = List<T>::size();
91 List<T>::setAddressableSize(currLen);
95 template<
class T,
int SizeMin>
105 const label currLen = List<T>::size();
108 capacity_ =
max(SizeMin,
max(len, label(2*capacity_)));
112 List<T>::resize_nocopy(capacity_);
118 List<T>::setAddressableSize(currLen);
123 template<
class T,
int SizeMin>
130 this->doReserve(nocopy, len);
131 List<T>::setAddressableSize(len);
137 template<
class T,
int SizeMin>
145 template<
class T,
int SizeMin>
155 template<
class T,
int SizeMin>
167 template<
class T,
int SizeMin>
179 template<
class T,
int SizeMin>
190 template<
class T,
int SizeMin>
191 template<
int AnySizeMin>
202 template<
class T,
int SizeMin>
213 template<
class T,
int SizeMin>
225 template<
class T,
int SizeMin>
228 std::initializer_list<T> lst
236 template<
class T,
int SizeMin>
248 template<
class T,
int SizeMin>
260 template<
class T,
int SizeMin>
261 template<
int AnySizeMin>
273 template<
class T,
int SizeMin>
286 template<
class T,
int SizeMin>
293 template<
class T,
int SizeMin>
294 inline std::streamsize
297 return std::streamsize(capacity_)*
sizeof(
T);
301 template<
class T,
int SizeMin>
307 this->doCapacity(
false, len);
311 template<
class T,
int SizeMin>
317 this->doCapacity(
true, len);
321 template<
class T,
int SizeMin>
331 template<
class T,
int SizeMin>
337 this->doReserve(
false, len);
341 template<
class T,
int SizeMin>
347 this->doReserve(
true, len);
351 template<
class T,
int SizeMin>
357 this->doResize(
false, len);
361 template<
class T,
int SizeMin>
367 this->doResize(
true, len);
371 template<
class T,
int SizeMin>
384 this->operator[](idx) = val;
390 template<
class T,
int SizeMin>
397 template<
class T,
int SizeMin>
405 template<
class T,
int SizeMin>
417 template<
class T,
int SizeMin>
421 if (currLen < capacity_)
432 template<
class T,
int SizeMin>
436 this->shrinkStorage();
441 template<
class T,
int SizeMin>
442 template<
int AnySizeMin>
449 if (this->cdata() == other.cdata())
458 std::swap(this->capacity_, other.capacity_);
462 template<
class T,
int SizeMin>
467 capacity_ = list.size();
472 template<
class T,
int SizeMin>
473 template<
int AnySizeMin>
481 if (this->cdata() == list.cdata())
495 template<
class T,
int SizeMin>
503 capacity_ = list.size();
508 template<
class T,
int SizeMin>
518 this->operator[](idx) = val;
523 template<
class T,
int SizeMin>
533 this->operator[](idx) = std::move(val);
538 template<
class T,
int SizeMin>
548 <<
"Attempted appending to self"
555 for (
const T& val : lst)
557 this->operator[](idx++) = val;
563 template<
class T,
int SizeMin>
574 for (
const T& val : lst)
576 this->operator[](idx++) = val;
582 template<
class T,
int SizeMin>
586 std::initializer_list<T> lst
592 for (
const T& val : lst)
594 this->operator[](idx++) = val;
600 template<
class T,
int SizeMin>
609 const label
n = lst.
size();
613 for (label i=0; i<
n; ++i)
615 this->operator[](idx++) = lst[i];
621 template<
class T,
int SizeMin>
631 <<
"Attempted appending to self"
636 resize(idx + list.size());
648 template<
class T,
int SizeMin>
661 template<
class T,
int SizeMin>
662 template<
int AnySizeMin>
675 template<
class T,
int SizeMin>
688 template<
class T,
int SizeMin>
691 if (this->
found(val))
703 template<
class T,
int SizeMin>
723 template<
class T,
int SizeMin>
742 return this->remove();
746 template<
class T,
int SizeMin>
752 return this->removeElements(this->validateRange(
range));
756 template<
class T,
int SizeMin>
759 std::initializer_list<label> start_size
762 return this->removeElements(this->validateRange(start_size));
766 template<
class T,
int SizeMin>
772 return this->subsetElements(this->validateRange(
range));
776 template<
class T,
int SizeMin>
779 std::initializer_list<label> start_size
782 return this->subsetElements(this->validateRange(start_size));
788 template<
class T,
int SizeMin>
799 return this->operator[](i);
803 template<
class T,
int SizeMin>
813 template<
class T,
int SizeMin>
823 template<
class T,
int SizeMin>
833 template<
class T,
int SizeMin>
844 template<
class T,
int SizeMin>
859 template<
class T,
int SizeMin>
860 template<
int AnySizeMin>
867 if (this->cdata() == list.cdata())
876 template<
class T,
int SizeMin>
879 std::initializer_list<T> lst
886 template<
class T,
int SizeMin>
897 template<
class T,
int SizeMin>
908 template<
class T,
int SizeMin>
924 template<
class T,
int SizeMin>
925 template<
int AnySizeMin>
932 if (this->cdata() == list.cdata())
942 template<
class T,
int SizeMin>
void resize(const label len)
label subset(const labelRange &range)
Retain a (start,size) subset from the list.
void setCapacity_unsafe(const label len) noexcept
constexpr DynamicList() noexcept
Default construct, an empty list without allocation.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
void setCapacity_nocopy(const label len)
void swap(DynamicList< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
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.
void shrinkStorage()
Shrink the allocated space to the number of elements used.
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
friend Ostream & operator(Ostream &os, const DynamicList< T, SizeMin > &list)
Write to Ostream.
void reserve(const label len)
label capacity() const noexcept
Size of the underlying storage.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
void setCapacity(const label len)
Alter the size of the underlying storage.
patchWriters resize(patchIds.size())
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
A range or interval of labels defined by a start and a size.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< T > & shrink()
Clear the indices and return a reference to the underlying List.
void reserve_nocopy(const label len)
A list that is sorted upon construction or when explicitly requested with the sort() method.
label size() const noexcept
The number of elements in the list.
errorManip< error > abort(error &err)
#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...
A 1D vector of objects of type <T> with a fixed length <N>.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void clearStorage()
Clear the list and delete storage.
T remove()
Remove and return the last element. Fatal on an empty list.
void transfer(List< T > &list)
Transfer contents of the argument List into this.
void resize_nocopy(const label len)
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
void size(const label n)
Older name for setAddressableSize.
label appendUniq(const T &val)
Append an element if not already in the list.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...