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 =
Foam::min(List<T>::size(), newCapacity);
71 List<T>::setAddressableSize(capacity_);
74 List<T>::resize_nocopy(newCapacity);
78 List<T>::resize_copy(currLen, newCapacity);
81 capacity_ = List<T>::size();
82 List<T>::setAddressableSize(currLen);
86 template<
class T,
int SizeMin>
96 const label currLen = List<T>::size();
100 Foam::ListPolicy::reserve_size<SizeMin, 2>(len, capacity_);
104 List<T>::resize_nocopy(capacity_);
110 List<T>::setAddressableSize(currLen);
115 template<
class T,
int SizeMin>
122 this->doReserve(nocopy, len);
129 template<
class T,
int SizeMin>
137 template<
class T,
int SizeMin>
143 reserve_nocopy(initialCapacity);
147 template<
class T,
int SizeMin>
150 const std::pair<label,label>& sizing
154 capacity_(
List<
T>::size())
160 template<
class T,
int SizeMin>
168 capacity_(
List<
T>::size())
172 template<
class T,
int SizeMin>
184 template<
class T,
int SizeMin>
187 const DynamicList<T, SizeMin>& list
195 template<
class T,
int SizeMin>
196 template<
int AnySizeMin>
203 capacity_(
List<
T>::size())
207 template<
class T,
int SizeMin>
214 capacity_(
List<
T>::size())
218 template<
class T,
int SizeMin>
225 List<
T>(list, indices),
230 template<
class T,
int SizeMin>
238 capacity_(
List<
T>::size())
242 template<
class T,
int SizeMin>
245 std::initializer_list<T> lst
253 template<
class T,
int SizeMin>
261 capacity_(
List<
T>::size())
265 template<
class T,
int SizeMin>
272 capacity_(list.capacity())
274 list.setCapacity_unsafe(0);
278 template<
class T,
int SizeMin>
279 template<
int AnySizeMin>
286 capacity_(list.capacity())
288 list.setCapacity_unsafe(0);
292 template<
class T,
int SizeMin>
305 template<
class T,
int SizeMin>
306 inline std::streamsize
309 return std::streamsize(capacity_)*
sizeof(
T);
313 template<
class T,
int SizeMin>
319 this->doCapacity(
false, len);
323 template<
class T,
int SizeMin>
329 this->doCapacity(
true, len);
333 template<
class T,
int SizeMin>
339 this->doReserve(
false, len);
343 template<
class T,
int SizeMin>
349 this->doReserve(
true, len);
353 template<
class T,
int SizeMin>
371 template<
class T,
int SizeMin>
377 this->doResize(
false, len);
381 template<
class T,
int SizeMin>
388 this->doResize(
true, len);
393 template<
class T,
int SizeMin>
399 this->doResize(
true, len);
403 template<
class T,
int SizeMin>
418 this->begin(oldLen), this->
end(), val
424 template<
class T,
int SizeMin>
431 template<
class T,
int SizeMin>
439 template<
class T,
int SizeMin>
443 if (currLen < capacity_)
452 template<
class T,
int SizeMin>
455 if (List<T>::empty())
464 template<
class T,
int SizeMin>
470 static_cast<const List<T>*
>(
this)
471 ==
static_cast<const List<T>*
>(&list)
478 this->shrink_to_fit();
481 UList<T>::swap(list);
488 template<
class T,
int SizeMin>
489 template<
int AnySizeMin>
497 static_cast<const List<T>*
>(
this)
498 ==
static_cast<const List<T>*
>(&other)
505 UList<T>::swap(other);
508 std::swap(this->capacity_, other.capacity_);
512 template<
class T,
int SizeMin>
521 template<
class T,
int SizeMin>
522 template<
int AnySizeMin>
531 static_cast<const List<T>*
>(
this)
532 ==
static_cast<const List<T>*
>(&list)
546 template<
class T,
int SizeMin>
547 template<
class... Args>
563 template<
class T,
int SizeMin>
576 template<
class T,
int SizeMin>
589 template<
class T,
int SizeMin>
598 <<
"Attempted push_back to self" 602 const label idx = List<T>::size();
605 std::copy(list.
begin(), list.
end(), this->begin(idx));
609 template<
class T,
int SizeMin>
619 std::copy(list.
begin(), list.
end(), this->begin(idx));
623 template<
class T,
int SizeMin>
626 std::initializer_list<T> list
630 resize(idx + list.size());
632 std::copy(list.begin(), list.end(), this->begin(idx));
636 template<
class T,
int SizeMin>
647 const label idx = this->size();
648 const label
n = list.
size();
651 auto iter = this->begin(idx);
653 for (label i = 0; i <
n; (void)++i, (
void)++iter)
660 template<
class T,
int SizeMin>
669 <<
"Attempted push_back to self" 673 const label idx = List<T>::size();
674 resize(idx + list.size());
676 std::move(list.begin(), list.end(), this->begin(idx));
682 template<
class T,
int SizeMin>
683 template<
int AnySizeMin>
689 push_back(std::move(
static_cast<List<T>&
>(list)));
694 template<
class T,
int SizeMin>
697 if (this->contains(val))
703 this->push_back(val);
709 template<
class T,
int SizeMin>
712 if (
n >= this->size())
723 template<
class T,
int SizeMin>
727 const label idx = List<T>::size() - 1;
735 const T& val = List<T>::operator[](idx);
737 List<T>::setAddressableSize(idx);
743 template<
class T,
int SizeMin>
762 return this->
remove();
766 template<
class T,
int SizeMin>
772 return this->removeElements(this->validateRange(
range));
776 template<
class T,
int SizeMin>
779 std::initializer_list<label> start_size
782 return this->removeElements(this->validateRange(start_size));
786 template<
class T,
int SizeMin>
792 return this->subsetElements(this->validateRange(
range));
796 template<
class T,
int SizeMin>
799 std::initializer_list<label> start_size
802 return this->subsetElements(this->validateRange(start_size));
808 template<
class T,
int SizeMin>
823 template<
class T,
int SizeMin>
833 template<
class T,
int SizeMin>
843 template<
class T,
int SizeMin>
849 doAssignDynList(lst);
853 template<
class T,
int SizeMin>
860 doAssignDynList(lst);
864 template<
class T,
int SizeMin>
875 doAssignDynList(lst);
879 template<
class T,
int SizeMin>
880 template<
int AnySizeMin>
888 static_cast<const List<T>*
>(
this)
889 ==
static_cast<const List<T>*
>(&list)
895 doAssignDynList(list);
899 template<
class T,
int SizeMin>
902 std::initializer_list<T> lst
905 doAssignDynList(lst);
909 template<
class T,
int SizeMin>
923 doAssignDynList(lst);
927 template<
class T,
int SizeMin>
938 template<
class T,
int SizeMin>
954 template<
class T,
int SizeMin>
955 template<
int AnySizeMin>
963 static_cast<const List<T>*
>(
this)
964 ==
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.
#define FOAM_UNLIKELY(cond)
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 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.
void reserve_exact(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
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)
void setCapacity_nocopy(const label len)
Alter the size of the underlying storage, without retaining old content.