Go to the documentation of this file.
34 template<
class T,
int SizeMin>
37 (this->ptrs_).setAddressableSize(len);
43 template<
class T,
int SizeMin>
51 template<
class T,
int SizeMin>
57 setAddressableSize(0);
61 template<
class T,
int SizeMin>
72 template<
class T,
int SizeMin>
79 capacity_(list.capacity_)
85 template<
class T,
int SizeMin>
95 template<
class T,
int SizeMin>
102 template<
class T,
int SizeMin>
109 template<
class T,
int SizeMin>
115 if (nextFree > capacity_)
118 nextFree = capacity_;
122 setAddressableSize(nextFree);
126 template<
class T,
int SizeMin>
129 if (nElem > capacity_)
133 capacity_ =
max(SizeMin,
max(nElem, label(2*capacity_)));
138 setAddressableSize(nextFree);
143 template<
class T,
int SizeMin>
146 auto& ptrs = this->ptrs_;
148 const label oldLen = ptrs.size();
150 if (newLen > capacity_)
153 capacity_ =
max(SizeMin,
max(newLen, label(2*capacity_)));
157 else if (newLen != oldLen)
160 for (label i=newLen; i<oldLen; ++i)
167 setAddressableSize(newLen);
171 template<
class T,
int SizeMin>
178 template<
class T,
int SizeMin>
181 (this->ptrs_).free();
182 setAddressableSize(0);
186 template<
class T,
int SizeMin>
194 template<
class T,
int SizeMin>
200 setAddressableSize(capacity_);
206 template<
class T,
int SizeMin>
210 if (capacity_ > nextFree)
213 setAddressableSize(capacity_);
216 capacity_ = nextFree;
218 setAddressableSize(nextFree);
223 template<
class T,
int SizeMin>
232 template<
class T,
int SizeMin>
233 template<
class... Args>
240 template<
class T,
int SizeMin>
243 const label idx = this->size();
245 this->ptrs_[idx] = ptr;
249 template<
class T,
int SizeMin>
256 template<
class T,
int SizeMin>
259 this->
append(ptr.release());
263 template<
class T,
int SizeMin>
266 this->
append(ptr.release());
270 template<
class T,
int SizeMin>
277 template<
class T,
int SizeMin>
284 template<
class T,
int SizeMin>
287 const label idx = this->size();
288 const label len = other.size();
292 for (label i=0; i < len; ++i)
294 set(idx + i, other.release(i));
301 template<
class T,
int SizeMin>
302 template<
int AnySizeMin>
308 const label idx = this->size();
309 const label len = other.size();
313 for (label i=0; i < len; ++i)
315 set(idx + i, other.release(i));
318 other.clearStorage();
322 template<
class T,
int SizeMin>
326 const label idx = (this->size() - 1);
334 this->ptrs_[idx] =
nullptr;
335 setAddressableSize(idx);
341 template<
class T,
int SizeMin>
342 template<
class... Args>
349 return this->
set(i,
new T(std::forward<Args>(
args)...));
353 template<
class T,
int SizeMin>
360 if (i >= this->size())
369 template<
class T,
int SizeMin>
380 template<
class T,
int SizeMin>
391 template<
class T,
int SizeMin>
395 std::unique_ptr<T>&& ptr
402 template<
class T,
int SizeMin>
409 return this->
set(i, ptr.
ptr());
413 template<
class T,
int SizeMin>
420 return this->
set(i, ptr.
ptr());
424 template<
class T,
int SizeMin>
435 template<
class T,
int SizeMin>
451 template<
class T,
int SizeMin>
467 template<
class T,
int SizeMin>
468 template<
int AnySizeMin>
475 if (this->cdata() == list.cdata())
485 template<
class T,
int SizeMin>
502 template<
class T,
int SizeMin>
519 template<
class T,
int SizeMin>
520 template<
int AnySizeMin>
527 if (this->cdata() == list.cdata())
void reserve(const label nElem)
Reserve allocation space for at least this size.
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 setSize(const label newLen)
Same as resize()
label expandStorage()
Expand the addressable size to fit the allocated capacity.
A class for managing temporary objects.
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.
void setCapacity(const label nElem)
Alter the size of the underlying storage.
patchWriters resize(patchIds.size())
T * release() noexcept
Return pointer to the managed object and release ownership.
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.
constexpr PtrDynList() noexcept
Construct null.
void emplace_append(Args &&... args)
Construct and append an element to the end of the list.
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)