41 #ifndef Foam_PtrDynList_H 42 #define Foam_PtrDynList_H 45 #include <type_traits> 53 template<
class T,
int SizeMin>
class PtrDynList;
59 template<
class T,
int SizeMin=64>
64 static_assert(SizeMin > 0,
"Invalid min size parameter");
83 inline explicit PtrDynList(
const std::pair<label,label>& sizing);
92 template<
int AnySizeMin>
126 inline void resize(
const label newLen);
163 template<
int AnySizeMin>
170 template<
int AnySizeMin>
175 template<
class... Args>
182 inline void push_back(std::unique_ptr<T>&& ptr);
197 template<
int AnySizeMin>
209 template<
class... Args>
213 template<
class... Args>
220 template<
class... Args>
229 inline autoPtr<T> set(
const label i, std::unique_ptr<T>&& ptr);
256 template<
int AnySizeMin>
266 template<
int AnySizeMin>
279 return this->
set(i, ptr.
release());
294 void append(std::unique_ptr<T>&& ptr)
316 template<
int AnySizeMin>
317 void append(PtrDynList<T, AnySizeMin>&& other)
constexpr PtrDynList() noexcept
Default construct.
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
void setCapacity_unsafe(const label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
A class for managing references or pointers (no reference counting)
void shrink()
Alias for shrink_to_fit()
void operator=(const PtrList< T > &list)
Copy (clone) assignment.
~PtrDynList()
Destructor, sync allocated size before list destruction.
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.
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 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...
T * release() noexcept
Release ownership and return the pointer.
void setSize(const label n)
Same as resize()
void clearStorage()
Clear the list and delete storage.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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...
void resize(const label newLen)
Alter the addressed list size.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
void reserve(const label len)
Reserve allocation space for at least this size.
A class for managing temporary objects.
Foam::argList args(argc, argv)
T & emplace(const label i, Args &&... args)
Same as emplace_set()
void setAddressableSize(const label n) noexcept
Adjust addressable size.
void clear()
Clear the addressed list, i.e. set the size to zero.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.