34 template<
class T,
int SizeMin>
42 template<
class T,
int SizeMin>
52 template<
class T,
int SizeMin>
55 const std::pair<label,label>& sizing
65 template<
class T,
int SizeMin>
76 template<
class T,
int SizeMin>
83 capacity_(list.capacity())
92 template<
class T,
int SizeMin>
93 template<
int AnySizeMin>
100 capacity_(list.capacity())
109 template<
class T,
int SizeMin>
120 template<
class T,
int SizeMin>
130 template<
class T,
int SizeMin>
140 Foam::ListPolicy::reserve_size<SizeMin, 2>(len, capacity_);
148 template<
class T,
int SizeMin>
154 const label currLen = PtrList<T>::size();
163 template<
class T,
int SizeMin>
166 auto& ptrs = this->ptrs_;
168 const label oldLen = ptrs.size();
170 if (capacity_ < newLen)
174 Foam::ListPolicy::reserve_size<SizeMin, 2>(newLen, capacity_);
178 else if (newLen != oldLen)
181 for (label i = newLen; i < oldLen; ++i)
193 template<
class T,
int SizeMin>
196 if (capacity_ < newLen)
200 Foam::ListPolicy::reserve_size<SizeMin, 2>(newLen, capacity_);
214 template<
class T,
int SizeMin>
222 template<
class T,
int SizeMin>
230 template<
class T,
int SizeMin>
234 if (currLen < capacity_)
243 template<
class T,
int SizeMin>
246 if (PtrList<T>::empty())
255 template<
class T,
int SizeMin>
264 template<
class T,
int SizeMin>
277 this->shrink_to_fit();
280 UPtrList<T>::swap(list);
287 template<
class T,
int SizeMin>
288 template<
int AnySizeMin>
304 UPtrList<T>::swap(other);
307 std::swap(this->capacity_, other.capacity_);
311 template<
class T,
int SizeMin>
323 PtrList<T>::transfer(list);
328 template<
class T,
int SizeMin>
329 template<
int AnySizeMin>
352 template<
class T,
int SizeMin>
353 template<
class... Args>
356 T* ptr =
new T(std::forward<Args>(
args)...);
357 this->push_back(ptr);
362 template<
class T,
int SizeMin>
365 const label idx = this->size();
367 this->ptrs_[idx] = ptr;
371 template<
class T,
int SizeMin>
374 this->push_back(ptr.release());
378 template<
class T,
int SizeMin>
381 this->push_back(ptr.release());
385 template<
class T,
int SizeMin>
388 this->push_back(ptr.
ptr());
392 template<
class T,
int SizeMin>
395 this->push_back(ptr.
ptr());
399 template<
class T,
int SizeMin>
402 const label idx = this->size();
403 const label len = other.
size();
407 for (label i = 0; i < len; ++i)
409 set(idx + i, other.
release(i));
416 template<
class T,
int SizeMin>
417 template<
int AnySizeMin>
430 <<
"Attempted push_back to self" 434 const label idx = this->size();
435 const label len = other.
size();
439 for (label i = 0; i < len; ++i)
441 set(idx + i, other.
release(i));
448 template<
class T,
int SizeMin>
451 if (
n >= this->size())
457 this->
resize(this->size() -
n);
462 template<
class T,
int SizeMin>
463 template<
class... Args>
470 if (i >= this->size())
478 template<
class T,
int SizeMin>
479 template<
class... Args>
486 return this->emplace_set(i, std::forward<Args>(
args)...);
490 template<
class T,
int SizeMin>
491 template<
class... Args>
498 if (i >= this->size())
506 template<
class T,
int SizeMin>
513 if (i >= this->size())
522 template<
class T,
int SizeMin>
526 std::unique_ptr<T>&& ptr
529 return this->
set(i, ptr.release());
533 template<
class T,
int SizeMin>
540 return this->
set(i, ptr.release());
544 template<
class T,
int SizeMin>
551 return this->
set(i, ptr.
ptr());
556 template<
class T,
int SizeMin>
563 return this->
set(i, ptr.
ptr());
567 template<
class T,
int SizeMin>
571 this->shrink_to_fit();
578 template<
class T,
int SizeMin>
594 template<
class T,
int SizeMin>
605 PtrList<T>::operator=(list);
610 template<
class T,
int SizeMin>
611 template<
int AnySizeMin>
631 template<
class T,
int SizeMin>
637 this->transfer(list);
641 template<
class T,
int SizeMin>
647 this->transfer(list);
651 template<
class T,
int SizeMin>
652 template<
int AnySizeMin>
658 this->transfer(list);
constexpr PtrDynList() noexcept
Default construct.
patchWriters resize(patchIds.size())
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.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing references or pointers (no reference counting)
autoPtr< T > set(const label i, T *ptr)
Set element to given pointer and return old element (can be null). Auto-sizes list as required...
void reserve_exact(const label len)
Reserve allocation space for at least this size. If allocation is required, uses the specified size w...
label squeezeNull()
Squeeze out intermediate nullptr entries in the list of pointers and adjust the addressable size acco...
void transfer(PtrList< T > &list)
Transfer contents of the argument PtrList into this.
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location). Auto-sizes list as required.
label size() const noexcept
The number of entries in the list.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
label capacity() const noexcept
Size of the underlying storage.
void reorder(const labelUList &oldToNew)
Reorder elements. Reordering must be unique (ie, shuffle).
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
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 resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
void clearStorage()
Clear the list and delete storage.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
T & try_emplace(const label i, Args &&... args)
Like emplace_set() but will not overwrite an occupied location.
void push_back(T *ptr)
Append an element to the end of the list.
A dynamically resizable PtrList with allocation management.
void swap(PtrList< T > &list)
Swap with plain PtrList content. Implies shrink_to_fit().
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
void shrink_unsafe()
Shrink the internal bookkeeping of the allocated space to the number of addressed elements without af...
triangles reserve(surf.size())
autoPtr< T > release(const label i)
Release ownership of the pointer at the given position.
void resize(const label newLen)
Alter the addressed list size.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
void reserve(const label len)
Reserve allocation space for at least this size.
A class for managing temporary objects.
Foam::argList args(argc, argv)
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
T & emplace(const label i, Args &&... args)
Same as emplace_set()
void clear()
Clear the addressed list, i.e. set the size to zero.