34 template<
class T,
int SizeMin>
42 template<
class T,
int SizeMin>
52 template<
class T,
int SizeMin>
63 template<
class T,
int SizeMin>
70 capacity_(list.capacity())
79 template<
class T,
int SizeMin>
80 template<
int AnySizeMin>
87 capacity_(list.capacity())
96 template<
class T,
int SizeMin>
107 template<
class T,
int SizeMin>
117 template<
class T,
int SizeMin>
126 capacity_ =
max(SizeMin,
max(len, label(2*capacity_)));
134 template<
class T,
int SizeMin>
137 auto& ptrs = this->ptrs_;
139 const label oldLen = ptrs.size();
141 if (capacity_ < newLen)
144 capacity_ =
max(SizeMin,
max(newLen, label(2*capacity_)));
148 else if (newLen != oldLen)
151 for (label i = newLen; i < oldLen; ++i)
163 template<
class T,
int SizeMin>
166 if (capacity_ < newLen)
169 capacity_ =
max(SizeMin,
max(newLen, label(2*capacity_)));
183 template<
class T,
int SizeMin>
191 template<
class T,
int SizeMin>
199 template<
class T,
int SizeMin>
203 if (currLen < capacity_)
213 template<
class T,
int SizeMin>
216 if (PtrList<T>::empty())
225 template<
class T,
int SizeMin>
234 template<
class T,
int SizeMin>
247 this->shrink_to_fit();
250 UPtrList<T>::swap(list);
257 template<
class T,
int SizeMin>
258 template<
int AnySizeMin>
274 UPtrList<T>::swap(other);
277 std::swap(this->capacity_, other.capacity_);
281 template<
class T,
int SizeMin>
293 PtrList<T>::transfer(list);
298 template<
class T,
int SizeMin>
299 template<
int AnySizeMin>
322 template<
class T,
int SizeMin>
323 template<
class... Args>
326 T* ptr =
new T(std::forward<Args>(
args)...);
327 this->push_back(ptr);
332 template<
class T,
int SizeMin>
335 const label idx = this->size();
337 this->ptrs_[idx] = ptr;
341 template<
class T,
int SizeMin>
344 this->push_back(ptr.release());
348 template<
class T,
int SizeMin>
351 this->push_back(ptr.release());
355 template<
class T,
int SizeMin>
358 this->push_back(ptr.
ptr());
362 template<
class T,
int SizeMin>
365 this->push_back(ptr.
ptr());
369 template<
class T,
int SizeMin>
372 const label idx = this->size();
373 const label len = other.
size();
377 for (label i = 0; i < len; ++i)
379 set(idx + i, other.
release(i));
386 template<
class T,
int SizeMin>
387 template<
int AnySizeMin>
400 <<
"Attempted push_back to self" 404 const label idx = this->size();
405 const label len = other.
size();
409 for (label i = 0; i < len; ++i)
411 set(idx + i, other.
release(i));
418 template<
class T,
int SizeMin>
421 if (
n >= this->size())
427 this->
resize(this->size() -
n);
432 template<
class T,
int SizeMin>
433 template<
class... Args>
440 if (i >= this->size())
448 template<
class T,
int SizeMin>
449 template<
class... Args>
456 return this->emplace_set(i, std::forward<Args>(
args)...);
460 template<
class T,
int SizeMin>
461 template<
class... Args>
468 if (i >= this->size())
476 template<
class T,
int SizeMin>
483 if (i >= this->size())
492 template<
class T,
int SizeMin>
496 std::unique_ptr<T>&& ptr
499 return this->
set(i, ptr.release());
503 template<
class T,
int SizeMin>
510 return this->
set(i, ptr.release());
514 template<
class T,
int SizeMin>
521 return this->
set(i, ptr.
ptr());
526 template<
class T,
int SizeMin>
533 return this->
set(i, ptr.
ptr());
537 template<
class T,
int SizeMin>
541 this->shrink_to_fit();
548 template<
class T,
int SizeMin>
564 template<
class T,
int SizeMin>
575 PtrList<T>::operator=(list);
580 template<
class T,
int SizeMin>
581 template<
int AnySizeMin>
601 template<
class T,
int SizeMin>
607 this->transfer(list);
611 template<
class T,
int SizeMin>
617 this->transfer(list);
621 template<
class T,
int SizeMin>
622 template<
int AnySizeMin>
628 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...
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.