Go to the documentation of this file.
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>
86 template<
class T,
int SizeMin>
93 template<
class T,
int SizeMin>
100 template<
class T,
int SizeMin>
109 capacity_ =
max(SizeMin,
max(len, label(2*capacity_)));
117 template<
class T,
int SizeMin>
120 auto& ptrs = this->ptrs_;
122 const label oldLen = ptrs.size();
124 if (capacity_ < newLen)
127 capacity_ =
max(SizeMin,
max(newLen, label(2*capacity_)));
131 else if (newLen != oldLen)
134 for (label i = newLen; i < oldLen; ++i)
146 template<
class T,
int SizeMin>
149 (this->ptrs_).free();
154 template<
class T,
int SizeMin>
162 template<
class T,
int SizeMin>
174 template<
class T,
int SizeMin>
178 if (currLen < capacity_)
189 template<
class T,
int SizeMin>
198 template<
class T,
int SizeMin>
199 template<
int AnySizeMin>
206 if (this->cdata() == other.cdata())
215 std::swap(this->capacity_, other.capacity_);
219 template<
class T,
int SizeMin>
220 template<
class... Args>
227 template<
class T,
int SizeMin>
230 const label idx = this->size();
232 this->ptrs_[idx] = ptr;
236 template<
class T,
int SizeMin>
243 template<
class T,
int SizeMin>
246 this->
append(ptr.release());
250 template<
class T,
int SizeMin>
253 this->
append(ptr.release());
257 template<
class T,
int SizeMin>
264 template<
class T,
int SizeMin>
271 template<
class T,
int SizeMin>
274 const label idx = this->size();
275 const label len = other.size();
279 for (label i=0; i < len; ++i)
281 set(idx + i, other.release(i));
288 template<
class T,
int SizeMin>
289 template<
int AnySizeMin>
295 const label idx = this->size();
296 const label len = other.size();
300 for (label i=0; i < len; ++i)
302 set(idx + i, other.release(i));
309 template<
class T,
int SizeMin>
313 const label idx = (this->size() - 1);
321 this->ptrs_[idx] =
nullptr;
328 template<
class T,
int SizeMin>
329 template<
class... Args>
336 return this->
set(i,
new T(std::forward<Args>(
args)...));
340 template<
class T,
int SizeMin>
347 if (i >= this->size())
356 template<
class T,
int SizeMin>
367 template<
class T,
int SizeMin>
378 template<
class T,
int SizeMin>
382 std::unique_ptr<T>&& ptr
389 template<
class T,
int SizeMin>
396 return this->
set(i, ptr.
ptr());
400 template<
class T,
int SizeMin>
407 return this->
set(i, ptr.
ptr());
411 template<
class T,
int SizeMin>
422 template<
class T,
int SizeMin>
438 template<
class T,
int SizeMin>
454 template<
class T,
int SizeMin>
455 template<
int AnySizeMin>
462 if (this->cdata() == list.cdata())
472 template<
class T,
int SizeMin>
489 template<
class T,
int SizeMin>
506 template<
class T,
int SizeMin>
507 template<
int AnySizeMin>
514 if (this->cdata() == list.cdata())
const T * set(const label i) const
Return const pointer to element (if set) or nullptr,.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
void swap(PtrDynList< T, AnySizeMin > &other)
Swap content, independent of sizing parameter.
A class for managing temporary objects.
label expandStorage() noexcept
Expand the addressable size to fit the allocated capacity.
label capacity() const noexcept
Size of the underlying storage.
void reorder(const labelUList &oldToNew)
Reorder elements. Reordering must be unique (ie, shuffle).
void append(T *ptr)
Append an element to the end of the list.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
A dynamically resizable PtrList with allocation management.
void resize(const label newLen)
Alter the addressed list size.
void shrink()
Shrink the allocated space to the number of elements used.
autoPtr< T > remove()
Remove and return the top element.
patchWriters resize(patchIds.size())
T * release() noexcept
Release ownership and return the pointer.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void clearStorage()
Clear the list and delete storage.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
void clear()
Clear the addressed list, i.e. set the size to zero.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
autoPtr< T > emplace(const label i, Args &&... args)
Construct and set an element.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
constexpr PtrDynList() noexcept
Default construct.
void emplace_append(Args &&... args)
Construct and append an element to the end of the list.
void reserve(const label len)
Reserve allocation space for at least this size.
Foam::argList args(argc, argv)
const T * get(const label i) const
Return const pointer to element (can be nullptr),.
A class for managing references or pointers (no reference counting)