PtrDynList< T, SizeMin > Class Template Reference

A dynamically resizable PtrList with allocation management. More...

Inheritance diagram for PtrDynList< T, SizeMin >:
[legend]
Collaboration diagram for PtrDynList< T, SizeMin >:
[legend]

Public Member Functions

constexpr PtrDynList () noexcept
 Default construct. More...
 
 PtrDynList (const label len)
 Construct with given capacity. More...
 
 PtrDynList (const PtrDynList< T, SizeMin > &list)
 Copy construct using 'clone()' method on each element. More...
 
 PtrDynList (PtrDynList< T, SizeMin > &&list)
 Move construct. More...
 
 PtrDynList (PtrList< T > &&list)
 Move construct from PtrList. More...
 
 PtrDynList (UList< T * > &list)
 Take ownership of pointers in the list, set old pointers to null. More...
 
 ~PtrDynList ()=default
 Destructor. More...
 
label capacity () const noexcept
 Size of the underlying storage. More...
 
const Tget (const label i) const
 
const Tset (const label i) const
 
void reserve (const label len)
 Reserve allocation space for at least this size. More...
 
void resize (const label newLen)
 Alter the addressed list size. More...
 
void setSize (const label n)
 Same as resize() More...
 
void clear ()
 Clear the addressed list, i.e. set the size to zero. More...
 
void clearStorage ()
 Clear the list and delete storage. More...
 
label expandStorage () noexcept
 Expand the addressable size to fit the allocated capacity. More...
 
void shrink ()
 Shrink the allocated space to the number of elements used. More...
 
label squeezeNull ()
 
template<int AnySizeMin>
void swap (PtrDynList< T, AnySizeMin > &other)
 Swap content, independent of sizing parameter. More...
 
template<class... Args>
void emplace_append (Args &&... args)
 Construct and append an element to the end of the list. More...
 
void append (T *ptr)
 Append an element to the end of the list. More...
 
void append (autoPtr< T > &ptr)
 Move append an element to the end of the list. More...
 
void append (autoPtr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (std::unique_ptr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (const refPtr< T > &ptr)
 Move or clone append a tmp to the end of the list. More...
 
void append (const tmp< T > &ptr)
 Move or clone append a tmp to the end of the list. More...
 
void append (PtrList< T > &&other)
 Move append another list to the end of this list. More...
 
template<int AnySizeMin>
void append (PtrDynList< T, AnySizeMin > &&other)
 Move append another list to the end of this list. More...
 
autoPtr< Tremove ()
 Remove and return the top element. More...
 
template<class... Args>
autoPtr< Templace (const label i, Args &&... args)
 Construct and set an element. More...
 
autoPtr< Tset (const label i, T *ptr)
 Set element to given pointer and return old element (can be null) More...
 
autoPtr< Tset (const label i, autoPtr< T > &ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, autoPtr< T > &&ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, std::unique_ptr< T > &&ptr)
 Set element to given pointer and return old element. More...
 
autoPtr< Tset (const label i, const refPtr< T > &ptr)
 Set element to given refPtr and return old element. More...
 
autoPtr< Tset (const label i, const tmp< T > &ptr)
 Set element to given tmp and return old element. More...
 
void reorder (const labelUList &oldToNew)
 Reorder elements. Reordering must be unique (ie, shuffle). More...
 
void operator= (const PtrList< T > &list)
 Copy (clone) assignment. More...
 
void operator= (const PtrDynList< T, SizeMin > &list)
 Copy (clone) assignment. More...
 
template<int AnySizeMin>
void operator= (const PtrDynList< T, AnySizeMin > &list)
 Copy (clone) assignment with different sizing parameters. More...
 
void operator= (PtrList< T > &&list)
 Move assignment. More...
 
void operator= (PtrDynList< T, SizeMin > &&list)
 Move assignment. More...
 
template<int AnySizeMin>
void operator= (PtrDynList< T, AnySizeMin > &&list)
 Move assignment with different sizing parameters. More...
 
template<class... Args>
Foam::autoPtr< Templace (const label i, Args &&... args)
 
- Public Member Functions inherited from PtrList< T >
constexpr PtrList () noexcept
 Default construct. More...
 
 PtrList (const label len)
 Construct with specified size, each element initialized to nullptr. More...
 
 PtrList (const PtrList< T > &list)
 Copy construct using 'clone()' method on each element. More...
 
 PtrList (PtrList< T > &&list)
 Move construct. More...
 
 PtrList (UList< T * > &list)
 Take ownership of pointers in the list, set old pointers to null. More...
 
template<class CloneArg >
 PtrList (const PtrList< T > &list, const CloneArg &cloneArgs)
 Copy construct using 'clone()' method on each element. More...
 
 PtrList (PtrList< T > &list, bool reuse)
 Construct as copy or re-use as specified. More...
 
 PtrList (const SLPtrList< T > &list)
 Copy construct using 'clone()' on each element of SLPtrList<T> More...
 
template<class INew >
 PtrList (Istream &is, const INew &inew)
 Construct from Istream using given Istream constructor class. More...
 
 PtrList (Istream &is)
 Construct from Istream using default Istream constructor class. More...
 
 ~PtrList ()
 Destructor. More...
 
template<class... Args>
PtrList< Tclone (Args &&... args) const
 Make a copy by cloning each of the list elements. More...
 
const Tset (const label i) const
 
void clear ()
 Clear the PtrList. Delete allocated entries and set size to zero. More...
 
void resize (const label newLen)
 Adjust size of PtrList. More...
 
void setSize (const label newLen)
 Same as resize() More...
 
template<class... Args>
void emplace_append (Args &&... args)
 Construct and append an element to the end of the list. More...
 
void append (T *ptr)
 Append an element to the end of the list. More...
 
void append (autoPtr< T > &ptr)
 Move append an element to the end of the list. More...
 
void append (autoPtr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (std::unique_ptr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (const refPtr< T > &ptr)
 Move or clone append a refPtr to the end of the list. More...
 
void append (const tmp< T > &ptr)
 Move or clone append a tmp to the end of the list. More...
 
void append (PtrList< T > &&other)
 Move append another list to the end of this list. More...
 
template<class... Args>
autoPtr< Templace (const label i, Args &&... args)
 Construct and set an element. More...
 
autoPtr< Tset (const label i, T *ptr)
 Set element to given pointer and return old element (can be null) More...
 
autoPtr< Tset (const label i, autoPtr< T > &ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, autoPtr< T > &&ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, std::unique_ptr< T > &&ptr)
 Set element to given unique_ptr and return old element. More...
 
autoPtr< Tset (const label i, const refPtr< T > &ptr)
 Set element to given refPtr and return old element. More...
 
autoPtr< Tset (const label i, const tmp< T > &ptr)
 Set element to given tmp and return old element. More...
 
autoPtr< Trelease (const label i)
 Release ownership of the pointer at the given position. More...
 
void transfer (PtrList< T > &list)
 Transfer into this list and annul the argument list. More...
 
void operator= (const PtrList< T > &list)
 Copy assignment. More...
 
void operator= (PtrList< T > &&list)
 Move assignment. More...
 
template<class... Args>
Foam::PtrList< Tclone (Args &&... args) const
 
template<class... Args>
Foam::autoPtr< Templace (const label i, Args &&... args)
 
- Public Member Functions inherited from UPtrList< T >
constexpr UPtrList () noexcept
 Default construct. More...
 
 UPtrList (const label len)
 Construct with specified size, each element initialized to nullptr. More...
 
 UPtrList (const UPtrList< T > &list)
 Copy construct (shallow copies addresses) More...
 
 UPtrList (UPtrList< T > &&list)
 Move construct. More...
 
 UPtrList (UPtrList< T > &list, bool reuse)
 Construct as shallow copy or re-use as specified. More...
 
 UPtrList (PtrList< T > &list)
 Shallow copy from PtrList. More...
 
 UPtrList (const UList< T * > &list)
 Construct from UList of pointers (shallow copy) More...
 
 UPtrList (UList< T > &list)
 Construct from UList, taking the address of each list element. More...
 
label size () const noexcept
 The number of elements in the list. More...
 
bool empty () const noexcept
 True if the list is empty (ie, size() is zero) More...
 
Tfirst ()
 Return reference to the first element of the list. More...
 
const Tfirst () const
 Return reference to first element of the list. More...
 
Tlast ()
 Return reference to the last element of the list. More...
 
const Tlast () const
 Return reference to the last element of the list. More...
 
const Ttest (const label i) const
 
Tget (const label i)
 
const Tget (const label i) const
 
const Tset (const label i) const
 
void clear ()
 Set list size to zero. More...
 
void resize (const label newLen)
 Change the size of the list. More...
 
void setSize (const label n)
 Alias for resize() More...
 
label squeezeNull ()
 Squeeze out intermediate nullptr entries in the list of pointers. More...
 
void append (T *ptr)
 Append an element to the end of the list. More...
 
void append (UPtrList< T > &&other)
 Move append another list to the end of this list. More...
 
void swap (UPtrList< T > &list)
 Swap content. More...
 
void transfer (UPtrList< T > &list)
 Transfer contents into this list and annul the argument. More...
 
Tset (const label i, T *ptr)
 
void reorder (const labelUList &oldToNew, const bool check=false)
 
void sortOrder (const labelUList &order, const bool check=false)
 
void checkNonNull () const
 Check and raise FatalError if any nullptr exists in the list. More...
 
const Toperator[] (const label i) const
 Return const reference to the element. More...
 
Toperator[] (const label i)
 Return reference to the element. More...
 
const Toperator() (const label i) const
 Return const pointer to the element - same as get(). More...
 
void operator= (const UPtrList< T > &list)
 Copy assignment (shallow copies addresses) More...
 
void operator= (UPtrList< T > &&list)
 Move assignment. More...
 
T ** begin_ptr () noexcept
 Iterator to begin of raw pointers traversal (use with caution) More...
 
T ** end_ptr () noexcept
 Iterator beyond end of raw pointers traversal (use with caution) More...
 
iterator begin () noexcept
 Return an iterator to begin of UPtrList traversal. More...
 
iterator end () noexcept
 Return iterator beyond end of UPtrList traversal. More...
 
const_iterator cbegin () const noexcept
 Return const_iterator to begin of UPtrList traversal. More...
 
const_iterator cend () const noexcept
 Return const_iterator beyond end of UPtrList traversal. More...
 
const_iterator begin () const noexcept
 Return const_iterator to begin of UPtrList traversal. More...
 
const_iterator end () const noexcept
 Return const_iterator beyond end of UPtrList traversal. More...
 

Additional Inherited Members

- Public Types inherited from UPtrList< T >
typedef T value_type
 Type of values the list contains. More...
 
typedef Treference
 A non-const reference to the value_type. More...
 
typedef const Tconst_reference
 A const reference to the value_type. More...
 
- Protected Member Functions inherited from PtrList< T >
template<class INew >
void readIstream (Istream &is, const INew &inew)
 Read from Istream using Istream constructor class. More...
 
void free ()
 Delete the allocated entries, but retain the list size. More...
 
- Protected Member Functions inherited from UPtrList< T >
void setAddressableSize (const label n) noexcept
 Adjust addressable size. More...
 
 UPtrList (Detail::PtrListDetail< T > &&ptrs)
 Low-level move construct. More...
 
- Protected Attributes inherited from UPtrList< T >
Detail::PtrListDetail< Tptrs_
 The list of pointers. More...
 

Detailed Description

template<class T, int SizeMin = 64>
class Foam::PtrDynList< T, SizeMin >

A dynamically resizable PtrList with allocation management.

See also
Foam::UPtrList Foam::PtrList
Source files

Definition at line 61 of file PtrDynList.H.

Constructor & Destructor Documentation

◆ PtrDynList() [1/6]

constexpr PtrDynList
inlineconstexprnoexcept

Default construct.

Definition at line 35 of file PtrDynListI.H.

◆ PtrDynList() [2/6]

PtrDynList ( const label  len)
inlineexplicit

Construct with given capacity.

Definition at line 43 of file PtrDynListI.H.

References UList< T >::setAddressableSize().

Here is the call graph for this function:

◆ PtrDynList() [3/6]

PtrDynList ( const PtrDynList< T, SizeMin > &  list)
inline

Copy construct using 'clone()' method on each element.

Definition at line 53 of file PtrDynListI.H.

◆ PtrDynList() [4/6]

PtrDynList ( PtrDynList< T, SizeMin > &&  list)
inline

Move construct.

Definition at line 64 of file PtrDynListI.H.

◆ PtrDynList() [5/6]

PtrDynList ( PtrList< T > &&  list)
inline

Move construct from PtrList.

Definition at line 77 of file PtrDynListI.H.

◆ PtrDynList() [6/6]

PtrDynList ( UList< T * > &  list)
inlineexplicit

Take ownership of pointers in the list, set old pointers to null.

Definition at line 88 of file PtrDynListI.H.

◆ ~PtrDynList()

~PtrDynList ( )
default

Destructor.

References UPtrList< T >::test().

Here is the call graph for this function:

Member Function Documentation

◆ capacity()

Foam::label capacity
inlinenoexcept

Size of the underlying storage.

Definition at line 98 of file PtrDynListI.H.

◆ get()

const T * get ( const label  i) const
inline

Return const pointer to element (can be nullptr), with bounds checking.

The return value can be tested as a bool.

Definition at line 110 of file PtrDynList.H.

◆ set() [1/7]

const T * set ( const label  i) const
inline

Return const pointer to element (if set) or nullptr, with bounds checking.

The return value can be tested as a bool.

Definition at line 115 of file PtrDynList.H.

◆ reserve()

void reserve ( const label  len)
inline

Reserve allocation space for at least this size.

Definition at line 105 of file PtrDynListI.H.

◆ resize()

void resize ( const label  newLen)
inline

Alter the addressed list size.

Definition at line 122 of file PtrDynListI.H.

Referenced by PtrDynList< T, SizeMin >::setSize().

Here is the caller graph for this function:

◆ setSize()

void setSize ( const label  n)
inline

Same as resize()

Definition at line 127 of file PtrDynList.H.

References PtrDynList< T, SizeMin >::resize().

Here is the call graph for this function:

◆ clear()

void clear
inline

Clear the addressed list, i.e. set the size to zero.

Allocated size does not change

Definition at line 151 of file PtrDynListI.H.

◆ clearStorage()

void clearStorage
inline

Clear the list and delete storage.

Definition at line 159 of file PtrDynListI.H.

◆ expandStorage()

Foam::label expandStorage
inlinenoexcept

Expand the addressable size to fit the allocated capacity.

Returns the previous addressable size.

Definition at line 167 of file PtrDynListI.H.

◆ shrink()

void shrink
inline

Shrink the allocated space to the number of elements used.

Definition at line 179 of file PtrDynListI.H.

◆ squeezeNull()

Foam::label squeezeNull
inline

Squeeze out intermediate nullptr entries in the list of pointers and adjust the addressable size accordingly.

Returns
the number of non-null entries

Definition at line 194 of file PtrDynListI.H.

◆ swap()

void swap ( PtrDynList< T, AnySizeMin > &  other)
inline

Swap content, independent of sizing parameter.

Definition at line 204 of file PtrDynListI.H.

◆ emplace_append()

void emplace_append ( Args &&...  args)
inline

Construct and append an element to the end of the list.

Definition at line 228 of file PtrDynListI.H.

◆ append() [1/8]

void append ( T ptr)
inline

Append an element to the end of the list.

Definition at line 235 of file PtrDynListI.H.

Referenced by fvMatrix< Type >::setInterfaces().

Here is the caller graph for this function:

◆ append() [2/8]

void append ( autoPtr< T > &  ptr)
inline

Move append an element to the end of the list.

Definition at line 244 of file PtrDynListI.H.

References append(), and autoPtr< T >::release().

Here is the call graph for this function:

◆ append() [3/8]

void append ( autoPtr< T > &&  ptr)
inline

Move append an element to the end of the list.

Definition at line 251 of file PtrDynListI.H.

References append().

Here is the call graph for this function:

◆ append() [4/8]

void append ( std::unique_ptr< T > &&  ptr)
inline

Move append an element to the end of the list.

Definition at line 258 of file PtrDynListI.H.

References append().

Here is the call graph for this function:

◆ append() [5/8]

void append ( const refPtr< T > &  ptr)
inline

Move or clone append a tmp to the end of the list.

Definition at line 265 of file PtrDynListI.H.

References append(), and refPtr< T >::ptr().

Here is the call graph for this function:

◆ append() [6/8]

void append ( const tmp< T > &  ptr)
inline

Move or clone append a tmp to the end of the list.

Definition at line 272 of file PtrDynListI.H.

References append(), and tmp< T >::ptr().

Here is the call graph for this function:

◆ append() [7/8]

void append ( PtrList< T > &&  other)
inline

Move append another list to the end of this list.

Definition at line 279 of file PtrDynListI.H.

References resize().

Here is the call graph for this function:

◆ append() [8/8]

void append ( PtrDynList< T, AnySizeMin > &&  other)
inline

Move append another list to the end of this list.

Definition at line 297 of file PtrDynListI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and resize().

Here is the call graph for this function:

◆ remove()

Foam::autoPtr< T > remove
inline

Remove and return the top element.

Definition at line 328 of file PtrDynListI.H.

References UList< T >::setAddressableSize().

Here is the call graph for this function:

◆ emplace() [1/2]

autoPtr< T > emplace ( const label  i,
Args &&...  args 
)
inline

Construct and set an element.

◆ set() [2/7]

Foam::autoPtr< T > set ( const label  i,
T ptr 
)
inline

Set element to given pointer and return old element (can be null)

Definition at line 359 of file PtrDynListI.H.

References resize().

Here is the call graph for this function:

◆ set() [3/7]

Foam::autoPtr< T > set ( const label  i,
autoPtr< T > &  ptr 
)
inline

Set element to given autoPtr and return old element.

Definition at line 375 of file PtrDynListI.H.

References autoPtr< T >::release().

Here is the call graph for this function:

◆ set() [4/7]

Foam::autoPtr< T > set ( const label  i,
autoPtr< T > &&  ptr 
)
inline

Set element to given autoPtr and return old element.

Definition at line 386 of file PtrDynListI.H.

◆ set() [5/7]

Foam::autoPtr< T > set ( const label  i,
std::unique_ptr< T > &&  ptr 
)
inline

Set element to given pointer and return old element.

Definition at line 397 of file PtrDynListI.H.

◆ set() [6/7]

Foam::autoPtr< T > set ( const label  i,
const refPtr< T > &  ptr 
)
inline

Set element to given refPtr and return old element.

Definition at line 408 of file PtrDynListI.H.

References refPtr< T >::ptr().

Here is the call graph for this function:

◆ set() [7/7]

Foam::autoPtr< T > set ( const label  i,
const tmp< T > &  ptr 
)
inline

Set element to given tmp and return old element.

Definition at line 419 of file PtrDynListI.H.

References tmp< T >::ptr().

Here is the call graph for this function:

◆ reorder()

void reorder ( const labelUList oldToNew)
inline

Reorder elements. Reordering must be unique (ie, shuffle).

Definition at line 430 of file PtrDynListI.H.

◆ operator=() [1/6]

void operator= ( const PtrList< T > &  list)
inline

Copy (clone) assignment.

Definition at line 441 of file PtrDynListI.H.

References PtrList< T >::operator=(), and interfaceDefinitions::size().

Here is the call graph for this function:

◆ operator=() [2/6]

void operator= ( const PtrDynList< T, SizeMin > &  list)
inline

Copy (clone) assignment.

Definition at line 457 of file PtrDynListI.H.

References PtrList< T >::operator=(), and interfaceDefinitions::size().

Here is the call graph for this function:

◆ operator=() [3/6]

void operator= ( const PtrDynList< T, AnySizeMin > &  list)
inline

Copy (clone) assignment with different sizing parameters.

Definition at line 474 of file PtrDynListI.H.

References PtrList< T >::operator=(), and interfaceDefinitions::size().

Here is the call graph for this function:

◆ operator=() [4/6]

void operator= ( PtrList< T > &&  list)
inline

Move assignment.

Definition at line 494 of file PtrDynListI.H.

References interfaceDefinitions::size(), and kinematicSingleLayer::transfer().

Here is the call graph for this function:

◆ operator=() [5/6]

void operator= ( PtrDynList< T, SizeMin > &&  list)
inline

Move assignment.

Definition at line 511 of file PtrDynListI.H.

References kinematicSingleLayer::transfer().

Here is the call graph for this function:

◆ operator=() [6/6]

void operator= ( PtrDynList< T, AnySizeMin > &&  list)
inline

Move assignment with different sizing parameters.

Definition at line 529 of file PtrDynListI.H.

References kinematicSingleLayer::transfer().

Here is the call graph for this function:

◆ emplace() [2/2]

Foam::autoPtr< T > emplace ( const label  i,
Args &&...  args 
)
inline

Definition at line 348 of file PtrDynListI.H.

References args, and T.


The documentation for this class was generated from the following files: