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");
107 inline void reserve(
const label len);
110 inline void resize(
const label newLen);
135 template<
int AnySizeMin>
142 template<
int AnySizeMin>
147 template<class... Args>
169 template<
int AnySizeMin>
178 template<class... Args>
214 template<
int AnySizeMin>
224 template<
int AnySizeMin>
237 return this->
set(i, ptr.release());
252 void append(std::unique_ptr<T>&& ptr)
274 template<
int AnySizeMin>
275 void append(PtrDynList<T, AnySizeMin>&& other)
constexpr PtrDynList() noexcept
Default construct.
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...
void transfer(PtrList< T > &list)
Transfer contents of the argument PtrList into this.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
friend Ostream & operator(Ostream &os, const UPtrList< T > &list)
Write UPtrList to Ostream.
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...
~PtrDynList()=default
Destructor.
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
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.
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...
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)
Construct and set a new element at given position, (discard old element at that location). Return reference to the new list element.
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.