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");
89 template<
int AnySizeMin>
111 inline void reserve(
const label len);
114 inline void resize(
const label newLen);
151 template<
int AnySizeMin>
158 template<
int AnySizeMin>
163 template<
class... Args>
185 template<
int AnySizeMin>
197 template<
class... Args>
201 template<
class... Args>
208 template<
class... Args>
217 inline autoPtr<T> set(
const label i, std::unique_ptr<T>&& ptr);
244 template<
int AnySizeMin>
254 template<
int AnySizeMin>
267 return this->
set(i, ptr.
release());
282 void append(std::unique_ptr<T>&& ptr)
304 template<
int AnySizeMin>
305 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.
A class for managing references or pointers (no reference counting)
void shrink()
Calls shrink_to_fit()
void operator=(const PtrList< T > &list)
Copy (clone) assignment.
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.
~PtrDynList()=default
Destructor.
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 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.