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_)
76 template<
class T,
int SizeMin>
87 template<
class T,
int SizeMin>
97 template<
class T,
int SizeMin>
106 capacity_ =
max(SizeMin,
max(len, label(2*capacity_)));
114 template<
class T,
int SizeMin>
117 auto& ptrs = this->ptrs_;
119 const label oldLen = ptrs.size();
121 if (capacity_ < newLen)
124 capacity_ =
max(SizeMin,
max(newLen, label(2*capacity_)));
128 else if (newLen != oldLen)
131 for (label i = newLen; i < oldLen; ++i)
143 template<
class T,
int SizeMin>
146 (this->ptrs_).free();
151 template<
class T,
int SizeMin>
159 template<
class T,
int SizeMin>
171 template<
class T,
int SizeMin>
175 if (currLen < capacity_)
186 template<
class T,
int SizeMin>
189 const label newLen = UPtrList<T>::squeezeNull();
195 template<
class T,
int SizeMin>
196 template<
int AnySizeMin>
212 UPtrList<T>::swap(other);
215 std::swap(this->capacity_, other.capacity_);
219 template<
class T,
int SizeMin>
220 template<
class... Args>
223 this->push_back(
new T(std::forward<Args>(
args)...));
227 template<
class T,
int SizeMin>
230 const label idx = this->size();
232 this->ptrs_[idx] = ptr;
236 template<
class T,
int SizeMin>
239 this->push_back(ptr.release());
243 template<
class T,
int SizeMin>
246 this->push_back(ptr.release());
250 template<
class T,
int SizeMin>
253 this->push_back(ptr.
ptr());
257 template<
class T,
int SizeMin>
260 this->push_back(ptr.
ptr());
264 template<
class T,
int SizeMin>
267 const label idx = this->size();
268 const label len = other.
size();
272 for (label i = 0; i < len; ++i)
274 set(idx + i, other.
release(i));
281 template<
class T,
int SizeMin>
282 template<
int AnySizeMin>
295 <<
"Attempted push_back to self" 299 const label idx = this->size();
300 const label len = other.
size();
304 for (label i = 0; i < len; ++i)
306 set(idx + i, other.
release(i));
313 template<
class T,
int SizeMin>
316 if (
n >= this->size())
322 this->
resize(this->size() -
n);
327 template<
class T,
int SizeMin>
331 const label idx = (this->size() - 1);
338 autoPtr<T> old(this->ptrs_[idx]);
339 this->ptrs_[idx] =
nullptr;
340 PtrList<T>::setAddressableSize(idx);
346 template<
class T,
int SizeMin>
347 template<
class... Args>
354 return this->
set(i,
new T(std::forward<Args>(
args)...));
358 template<
class T,
int SizeMin>
365 if (i >= this->size())
374 template<
class T,
int SizeMin>
378 std::unique_ptr<T>&& ptr
381 return this->
set(i, ptr.release());
385 template<
class T,
int SizeMin>
392 return this->
set(i, ptr.release());
396 template<
class T,
int SizeMin>
403 return this->
set(i, ptr.
ptr());
408 template<
class T,
int SizeMin>
415 return this->
set(i, ptr.
ptr());
419 template<
class T,
int SizeMin>
430 template<
class T,
int SizeMin>
446 template<
class T,
int SizeMin>
457 PtrList<T>::operator=(list);
462 template<
class T,
int SizeMin>
463 template<
int AnySizeMin>
483 template<
class T,
int SizeMin>
494 PtrList<T>::transfer(list);
500 template<
class T,
int SizeMin>
511 PtrList<T>::transfer(list);
517 template<
class T,
int SizeMin>
518 template<
int AnySizeMin>
533 PtrList<T>::transfer(list);
autoPtr< T > remove()
Remove and return the top element. Can be called on an empty 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 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 shrink()
Shrink the allocated space to the number of elements used.
label squeezeNull()
Squeeze out intermediate nullptr entries in the list of pointers and adjust the addressable size acco...
label size() const noexcept
The number of elements in the list.
void emplace_back(Args &&... args)
Construct an element at the end of the list.
label capacity() const noexcept
Size of the underlying storage.
void reorder(const labelUList &oldToNew)
Reorder elements. Reordering must be unique (ie, shuffle).
autoPtr< T > emplace(const label i, Args &&... args)
Construct and set an element.
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...
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
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.
void push_back(T *ptr)
Append an element to the end of the list.
A dynamically resizable PtrList with allocation management.
void swap(PtrDynList< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
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.
void clear()
Clear the addressed list, i.e. set the size to zero.