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);
137 template<
class T,
int SizeMin>
145 template<
class T,
int SizeMin>
151 reserve_nocopy(initialCapacity);
155 template<
class T,
int SizeMin>
163 capacity_(
List<
T>::size())
167 template<
class T,
int SizeMin>
179 template<
class T,
int SizeMin>
182 const DynamicList<T, SizeMin>& list
190 template<
class T,
int SizeMin>
191 template<
int AnySizeMin>
198 capacity_(
List<
T>::size())
202 template<
class T,
int SizeMin>
209 capacity_(
List<
T>::size())
213 template<
class T,
int SizeMin>
220 List<
T>(list, indices),
225 template<
class T,
int SizeMin>
233 capacity_(
List<
T>::size())
237 template<
class T,
int SizeMin>
240 std::initializer_list<T> lst
248 template<
class T,
int SizeMin>
256 capacity_(
List<
T>::size())
260 template<
class T,
int SizeMin>
267 capacity_(list.capacity())
269 list.setCapacity_unsafe(0);
273 template<
class T,
int SizeMin>
274 template<
int AnySizeMin>
281 capacity_(list.capacity())
283 list.setCapacity_unsafe(0);
287 template<
class T,
int SizeMin>
300 template<
class T,
int SizeMin>
301 inline std::streamsize
304 return std::streamsize(capacity_)*
sizeof(
T);
308 template<
class T,
int SizeMin>
314 this->doCapacity(
false, len);
318 template<
class T,
int SizeMin>
324 this->doCapacity(
true, len);
328 template<
class T,
int SizeMin>
338 template<
class T,
int SizeMin>
344 this->doReserve(
false, len);
348 template<
class T,
int SizeMin>
354 this->doReserve(
true, len);
358 template<
class T,
int SizeMin>
364 this->doResize(
false, len);
368 template<
class T,
int SizeMin>
375 this->doResize(
true, len);
380 template<
class T,
int SizeMin>
386 this->doResize(
true, len);
390 template<
class T,
int SizeMin>
411 template<
class T,
int SizeMin>
418 template<
class T,
int SizeMin>
426 template<
class T,
int SizeMin>
430 if (currLen < capacity_)
440 template<
class T,
int SizeMin>
443 if (List<T>::empty())
452 template<
class T,
int SizeMin>
456 this->shrink_to_fit();
461 template<
class T,
int SizeMin>
467 static_cast<const List<T>*
>(
this)
468 ==
static_cast<const List<T>*
>(&list)
475 this->shrink_to_fit();
478 UList<T>::swap(list);
485 template<
class T,
int SizeMin>
486 template<
int AnySizeMin>
494 static_cast<const List<T>*
>(
this)
495 ==
static_cast<const List<T>*
>(&other)
502 UList<T>::swap(other);
505 std::swap(this->capacity_, other.capacity_);
509 template<
class T,
int SizeMin>
518 template<
class T,
int SizeMin>
519 template<
int AnySizeMin>
528 static_cast<const List<T>*
>(
this)
529 ==
static_cast<const List<T>*
>(&list)
543 template<
class T,
int SizeMin>
544 template<
class... Args>
560 template<
class T,
int SizeMin>
573 template<
class T,
int SizeMin>
586 template<
class T,
int SizeMin>
595 <<
"Attempted push_back to self" 599 const label idx = List<T>::size();
606 template<
class T,
int SizeMin>
620 template<
class T,
int SizeMin>
623 std::initializer_list<T> list
627 resize(idx + list.size());
629 std::copy(list.begin(), list.end(), this->
begin(idx));
633 template<
class T,
int SizeMin>
644 const label idx = this->size();
645 const label
n = list.
size();
649 auto iter = this->
begin(idx);
651 for (label i = 0; i <
n; (void)++i, (
void)++iter)
658 template<
class T,
int SizeMin>
667 <<
"Attempted push_back to self" 671 const label idx = List<T>::size();
672 resize(idx + list.size());
674 std::move(list.begin(), list.end(), this->
begin(idx));
680 template<
class T,
int SizeMin>
681 template<
int AnySizeMin>
687 push_back(std::move(
static_cast<List<T>&
>(list)));
692 template<
class T,
int SizeMin>
695 if (this->contains(val))
701 this->push_back(val);
707 template<
class T,
int SizeMin>
710 if (
n >= this->size())
721 template<
class T,
int SizeMin>
725 const label idx = List<T>::size() - 1;
733 const T& val = List<T>::operator[](idx);
735 List<T>::setAddressableSize(idx);
741 template<
class T,
int SizeMin>
760 return this->
remove();
764 template<
class T,
int SizeMin>
770 return this->removeElements(this->validateRange(
range));
774 template<
class T,
int SizeMin>
777 std::initializer_list<label> start_size
780 return this->removeElements(this->validateRange(start_size));
784 template<
class T,
int SizeMin>
790 return this->subsetElements(this->validateRange(
range));
794 template<
class T,
int SizeMin>
797 std::initializer_list<label> start_size
800 return this->subsetElements(this->validateRange(start_size));
806 template<
class T,
int SizeMin>
821 template<
class T,
int SizeMin>
831 template<
class T,
int SizeMin>
841 template<
class T,
int SizeMin>
847 doAssignDynList(lst);
851 template<
class T,
int SizeMin>
858 doAssignDynList(lst);
862 template<
class T,
int SizeMin>
873 doAssignDynList(lst);
877 template<
class T,
int SizeMin>
878 template<
int AnySizeMin>
886 static_cast<const List<T>*
>(
this)
887 ==
static_cast<const List<T>*
>(&list)
893 doAssignDynList(list);
897 template<
class T,
int SizeMin>
900 std::initializer_list<T> lst
903 doAssignDynList(lst);
907 template<
class T,
int SizeMin>
921 doAssignDynList(lst);
925 template<
class T,
int SizeMin>
936 template<
class T,
int SizeMin>
952 template<
class T,
int SizeMin>
953 template<
int AnySizeMin>
961 static_cast<const List<T>*
>(
this)
962 ==
static_cast<const List<T>*
>(&list)
void size(const label n)
Older name for setAddressableSize.
friend Ostream & operator(Ostream &os, const DynamicList< T, SizeMin > &list)
Write to Ostream.
patchWriters resize(patchIds.size())
A 1D vector of objects of type <T> with a fixed length <N>.
iterator begin() noexcept
Return an iterator to begin traversing the FixedList.
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...
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr DynamicList() noexcept
Default construct, an empty list without allocation.
A range or interval of labels defined by a start and a size.
void shrink_unsafe()
Shrink the internal bookkeeping of the allocated space to the number of addressed elements without af...
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
iterator end() noexcept
Return an iterator to end traversing the FixedList.
void setCapacity(const label len)
Alter the size of the underlying storage.
void resize_fill(const label len, const T &val)
Alter addressable size and set val for all addressed entries.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
label capacity() const noexcept
Size of the underlying storage.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
std::streamsize capacity_bytes() const noexcept
Number of contiguous bytes of the underlying storage.
label size() const noexcept
The number of elements in the list.
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.
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)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
void setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void push_back(const T &val)
Copy append an element to the end of this list.
void swap(List< T > &list)
Swap with plain List content. Implies shrink_to_fit().
label push_uniq(const T &val)
Append an element if not already in the list.
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 clearStorage()
Clear the list and delete storage.
label subset(const labelRange &range)
Retain a (start,size) subset from the list.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
iterator end() noexcept
Return an iterator to end traversing the UList.
Foam::argList args(argc, argv)
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.