34template<
class T,
int SizeMin>
42template<
class T,
int SizeMin>
52template<
class T,
int SizeMin>
55 std::pair<label,label> sizing
65template<
class T,
int SizeMin>
76template<
class T,
int SizeMin>
89template<
class T,
int SizeMin>
90template<
int AnySizeMin>
103template<
class T,
int SizeMin>
114template<
class T,
int SizeMin>
124template<
class T,
int SizeMin>
148template<
class T,
int SizeMin>
168template<
class T,
int SizeMin>
172 const label oldLen = ptrs.size();
174 if (capacity_ < newLen)
179 else if (newLen != oldLen)
182 for (label i = newLen; i < oldLen; ++i)
194template<
class T,
int SizeMin>
218template<
class T,
int SizeMin>
226template<
class T,
int SizeMin>
236template<
class T,
int SizeMin>
240 if (currLen < capacity_)
249template<
class T,
int SizeMin>
258template<
class T,
int SizeMin>
274 this->shrink_to_fit();
284template<
class T,
int SizeMin>
285template<
int AnySizeMin>
307 std::swap(this->capacity_, other.capacity_);
311template<
class T,
int SizeMin>
323template<
class T,
int SizeMin>
324template<
int AnySizeMin>
351template<
class T,
int SizeMin>
352template<
class... Args>
355 T* ptr =
new T(std::forward<Args>(
args)...);
361template<
class T,
int SizeMin>
364 const label idx = this->
size();
366 this->
ptrs_[idx] = ptr;
370template<
class T,
int SizeMin>
377template<
class T,
int SizeMin>
384template<
class T,
int SizeMin>
391template<
class T,
int SizeMin>
398template<
class T,
int SizeMin>
401 const label idx = this->size();
402 const label len = other.size();
406 for (label i = 0; i < len; ++i)
408 set(idx + i, other.release(i));
415template<
class T,
int SizeMin>
416template<
int AnySizeMin>
432 <<
"Attempted push_back to self"
436 const label idx = this->size();
437 const label len = other.size();
441 for (label i = 0; i < len; ++i)
443 set(idx + i, other.release(i));
446 other.clearStorage();
450template<
class T,
int SizeMin>
453 if (
n >= this->size())
464template<
class T,
int SizeMin>
465template<
class... Args>
472 if (i >= this->size())
480template<
class T,
int SizeMin>
481template<
class... Args>
492template<
class T,
int SizeMin>
493template<
class... Args>
500 if (i >= this->size())
508template<
class T,
int SizeMin>
515 if (i >= this->size())
524template<
class T,
int SizeMin>
528 std::unique_ptr<T>&& ptr
531 return this->
set(i, ptr.release());
535template<
class T,
int SizeMin>
542 return this->
set(i, ptr.release());
546template<
class T,
int SizeMin>
553 return this->
set(i, ptr.
ptr());
558template<
class T,
int SizeMin>
565 return this->
set(i, ptr.ptr());
569template<
class T,
int SizeMin>
578 return this->ptrs_.printAddresses(
os, capacity_);
582 return UPtrList<T>::printAddresses(
os);
589template<
class T,
int SizeMin>
592 const UPtrList<T>& list
599 static_cast<const UPtrList<T>*
>(
this)
600 ==
static_cast<const UPtrList<T>*
>(&list)
612template<
class T,
int SizeMin>
635template<
class T,
int SizeMin>
636template<
int AnySizeMin>
660template<
class T,
int SizeMin>
670template<
class T,
int SizeMin>
680template<
class T,
int SizeMin>
681template<
int AnySizeMin>
687 this->transfer(list);
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A dynamically resizable PtrList with allocation management.
T & emplace(const label i, Args &&... args)
Same as emplace_set().
void transfer(PtrList< T > &list)
Transfer contents of the argument PtrList into this.
constexpr PtrDynList() noexcept
Default construct.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Ostream & printAddresses(Ostream &os, const bool full=false) const
Print pointer addresses to Ostream (debugging only).
void push_back(T *ptr)
Append an element to the end of the list.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void setCapacity_unsafe(label len) noexcept
Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory manage...
void swap(PtrList< T > &list)
Swap with plain PtrList content. Implies shrink_to_fit().
void reserve_exact(const label len)
Reserve allocation space for at least this size. If allocation is required, uses the specified size w...
void shrink_to_fit()
Shrink the allocated space to the number of elements used.
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location)....
void clearStorage()
Clear the list and delete storage.
void resize_null(const label len)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
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.
T & try_emplace(const label i, Args &&... args)
Like emplace_set() but will not overwrite an occupied location.
label capacity() const noexcept
label squeezeNull()
Squeeze out intermediate nullptr entries in the list of pointers and adjust the addressable size acco...
void resize(const label len)
Alter the addressed list size.
void reserve(const label len)
Reserve allocation space for at least this size.
void clear()
Clear the addressed list, i.e. set the size to zero.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
void operator=(const UPtrList< T > &list)
Copy assignment.
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location).
T & try_emplace(const label i, Args &&... args)
Like emplace_set() but will not overwrite an occupied (non-null) location.
void free()
Free memory and nullify all entries. Does not change the list size.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
constexpr PtrList() noexcept
Default construct.
void resize(const label newLen)
Adjust size of PtrList.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
T & first()
Reference to the first element of the list.
Ostream & printAddresses(Ostream &os) const
Print pointer addresses to Ostream (debugging only).
label size() const noexcept
The number of entries in the list.
label squeezeNull()
Squeeze out nullptr entries in the list of pointers after which any null pointers will be at the end ...
Detail::PtrListDetail< Foam::Field< label > > ptrs_
void setAddressableSize(const label n) noexcept
Adjust addressable size.
void swap(UPtrList< T > &list) noexcept
Swap content.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing references or pointers (no reference counting).
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
IntType reserve_size(IntType requested, IntType capacity) noexcept
Calculate a reserve size (eg, doubling) based on the requested length and the current capacity.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
triangles reserve(surf.size())
Foam::argList args(argc, argv)
#define FOAM_UNLIKELY(cond)