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>
155 template<
class T,
int SizeMin>
163 capacity_(
List<
T>::size())
167 template<
class T,
int SizeMin>
175 capacity_(
List<
T>::size())
179 template<
class T,
int SizeMin>
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>
272 template<
class T,
int SizeMin>
273 template<
int AnySizeMin>
285 template<
class T,
int SizeMin>
292 capacity_(
List<
T>::size())
298 template<
class T,
int SizeMin>
299 inline std::streamsize
302 return std::streamsize(capacity_)*
sizeof(
T);
306 template<
class T,
int SizeMin>
312 this->doCapacity(
false, len);
316 template<
class T,
int SizeMin>
322 this->doCapacity(
true, len);
326 template<
class T,
int SizeMin>
336 template<
class T,
int SizeMin>
342 this->doReserve(
false, len);
346 template<
class T,
int SizeMin>
352 this->doReserve(
true, len);
356 template<
class T,
int SizeMin>
362 this->doResize(
false, len);
366 template<
class T,
int SizeMin>
372 this->doResize(
true, len);
376 template<
class T,
int SizeMin>
389 this->operator[](idx) = val;
395 template<
class T,
int SizeMin>
402 template<
class T,
int SizeMin>
410 template<
class T,
int SizeMin>
422 template<
class T,
int SizeMin>
426 if (currLen < capacity_)
437 template<
class T,
int SizeMin>
441 this->shrinkStorage();
446 template<
class T,
int SizeMin>
447 template<
int AnySizeMin>
455 static_cast<const List<T>*
>(
this)
456 ==
static_cast<const List<T>*
>(&other)
463 UList<T>::swap(other);
466 std::swap(this->capacity_, other.capacity_);
470 template<
class T,
int SizeMin>
475 capacity_ = list.
size();
480 template<
class T,
int SizeMin>
481 template<
int AnySizeMin>
490 static_cast<const List<T>*
>(
this)
491 ==
static_cast<const List<T>*
>(&list)
506 template<
class T,
int SizeMin>
507 template<
class... Args>
518 this->operator[](idx) =
T(std::forward<Args>(
args)...);
523 template<
class T,
int SizeMin>
532 this->operator[](idx) = val;
536 template<
class T,
int SizeMin>
545 this->operator[](idx) = std::move(val);
549 template<
class T,
int SizeMin>
558 <<
"Attempted push_back to self" 562 label idx = List<T>::size();
565 for (
const T& val : lst)
567 this->operator[](idx++) = val;
572 template<
class T,
int SizeMin>
576 const FixedList<T, N>& lst
579 label idx = List<T>::size();
582 for (
const T& val : lst)
584 this->operator[](idx++) = val;
589 template<
class T,
int SizeMin>
592 std::initializer_list<T> lst
595 label idx = List<T>::size();
598 for (
const T& val : lst)
600 this->operator[](idx++) = val;
605 template<
class T,
int SizeMin>
609 const IndirectListBase<T, Addr>& lst
612 label idx = List<T>::size();
613 const label
n = lst.size();
617 for (label i=0; i<
n; ++i)
619 this->operator[](idx++) = lst[i];
624 template<
class T,
int SizeMin>
633 <<
"Attempted push_back to self" 637 label idx = List<T>::size();
649 template<
class T,
int SizeMin>
650 template<
int AnySizeMin>
656 push_back(std::move(
static_cast<List<T>&
>(list)));
661 template<
class T,
int SizeMin>
664 if (this->contains(val))
670 this->push_back(val);
676 template<
class T,
int SizeMin>
679 if (
n >= this->size())
690 template<
class T,
int SizeMin>
694 const label idx = List<T>::size() - 1;
702 const T& val = List<T>::operator[](idx);
704 List<T>::setAddressableSize(idx);
710 template<
class T,
int SizeMin>
729 return this->
remove();
733 template<
class T,
int SizeMin>
739 return this->removeElements(this->validateRange(
range));
743 template<
class T,
int SizeMin>
746 std::initializer_list<label> start_size
749 return this->removeElements(this->validateRange(start_size));
753 template<
class T,
int SizeMin>
759 return this->subsetElements(this->validateRange(
range));
763 template<
class T,
int SizeMin>
766 std::initializer_list<label> start_size
769 return this->subsetElements(this->validateRange(start_size));
775 template<
class T,
int SizeMin>
786 return this->operator[](i);
790 template<
class T,
int SizeMin>
800 template<
class T,
int SizeMin>
810 template<
class T,
int SizeMin>
816 doAssignDynList(lst);
820 template<
class T,
int SizeMin>
827 doAssignDynList(lst);
831 template<
class T,
int SizeMin>
842 doAssignDynList(lst);
846 template<
class T,
int SizeMin>
847 template<
int AnySizeMin>
855 static_cast<const List<T>*
>(
this)
856 ==
static_cast<const List<T>*
>(&list)
862 doAssignDynList(list);
866 template<
class T,
int SizeMin>
869 std::initializer_list<T> lst
872 doAssignDynList(lst);
876 template<
class T,
int SizeMin>
890 doAssignDynList(lst);
894 template<
class T,
int SizeMin>
905 template<
class T,
int SizeMin>
921 template<
class T,
int SizeMin>
922 template<
int AnySizeMin>
930 static_cast<const List<T>*
>(
this)
931 ==
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>.
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
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 resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
void setCapacity(const label len)
Alter the size of the underlying storage.
void shrinkStorage()
Shrink the allocated space to the number of elements used.
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 swap(DynamicList< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
label capacity() const noexcept
Size of the underlying storage.
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 min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
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()
Shrink the allocated space to the number of elements used.
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.
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 Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
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...
Foam::argList args(argc, argv)
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.
static constexpr const zero Zero
Global zero (0)