PtrList< T > Class Template Reference

A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used for subscript bounds checking, etc. More...

Inheritance diagram for PtrList< T >:
Collaboration diagram for PtrList< T >:

Public Member Functions

 PtrList ()
 Null Constructor. More...
 
 PtrList (const label)
 Construct with size specified. More...
 
 PtrList (const PtrList< T > &)
 Copy constructor. More...
 
template<class CloneArg >
 PtrList (const PtrList< T > &, const CloneArg &)
 Copy constructor with additional argument for clone. More...
 
 PtrList (PtrList< T > &&)
 Move constructor. More...
 
 PtrList (PtrList< T > &, bool reuse)
 Construct as copy or reuse as specified. More...
 
 PtrList (const SLPtrList< T > &)
 Construct as copy of SLPtrList<T> More...
 
template<class INew >
 PtrList (Istream &, const INew &)
 Construct from Istream using given Istream constructor class. More...
 
 PtrList (Istream &)
 Construct from Istream using default Istream constructor class. More...
 
 ~PtrList ()
 Destructor. More...
 
void setSize (const label)
 Reset size of PtrList. If extending the PtrList, new entries are. More...
 
void resize (const label)
 Alias for setSize(const label) More...
 
void shrink ()
 Shrink the allocated space to the number of elements used. More...
 
void clear ()
 Clear the PtrList, i.e. set size to zero deleting all the. More...
 
void append (T *)
 Append an element at the end of the list. More...
 
void append (const autoPtr< T > &)
 Append an element at the end of the list. More...
 
void append (const tmp< T > &)
 Append an element at the end of the list. More...
 
void transfer (PtrList< T > &)
 Transfer the contents of the argument PtrList into this PtrList. More...
 
bool set (const label) const
 Is element set. More...
 
autoPtr< Tset (const label, T *)
 Set element to given T* and return old element (can be nullptr) More...
 
autoPtr< Tset (const label, const autoPtr< T > &)
 Set element to given autoPtr<T> and return old element. More...
 
autoPtr< Tset (const label, const tmp< T > &)
 Set element to given tmp<T> and return old element. More...
 
void reorder (const labelUList &oldToNew)
 Reorders elements. Ordering does not have to be done in. More...
 
void shuffle (const labelUList &newToOld)
 Reorders elements. Ordering does not have to be done in. More...
 
void operator= (const PtrList< T > &)
 Assignment operator. More...
 
void operator= (PtrList< T > &&)
 Move assignment operator. More...
 
- Public Member Functions inherited from UPtrList< T >
 UPtrList ()
 Null Constructor. More...
 
 UPtrList (const label)
 Construct with size specified. More...
 
 UPtrList (UPtrList< T > &, bool reuse)
 Construct as copy or reuse as specified. More...
 
label size () const
 Return the number of elements in the UPtrList. More...
 
bool empty () const
 Return true if the UPtrList 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...
 
void setSize (const label)
 Reset size of UPtrList. This can only be used to set the size. More...
 
void resize (const label)
 Reset size of UPtrList. This can only be used to set the size. More...
 
void clear ()
 Clear the UPtrList, i.e. set size to zero. More...
 
void append (T *)
 Append an element at the end of the list. More...
 
void transfer (UPtrList< T > &)
 Transfer the contents of the argument UPtrList into this. More...
 
bool set (const label) const
 Is element set. More...
 
Tset (const label, T *)
 Set element. Return old element (can be nullptr). More...
 
void reorder (const labelUList &oldToNew)
 Reorders elements. Ordering does not have to be done in. More...
 
void shuffle (const labelUList &newToOld)
 Reorders elements. Ordering does not have to be done in. More...
 
template<class T2 >
UPtrList< T2 > convert ()
 Convert to list of different pointer type. More...
 
template<class T2 >
UPtrList< const T2 > convert () const
 Convert to list of different pointer type. More...
 
const Toperator[] (const label) const
 Return element const reference. More...
 
Toperator[] (const label)
 Return element reference. More...
 
const Toperator() (const label) const
 Return element const pointer. More...
 
Toperator() (const label)
 Return element const pointer. More...
 
iterator begin ()
 Return an iterator to begin traversing the UPtrList. More...
 
iterator end ()
 Return an iterator to end traversing the UPtrList. More...
 
const_iterator cbegin () const
 Return an const_iterator to begin traversing the UPtrList. More...
 
const_iterator cend () const
 Return an const_iterator to end traversing the UPtrList. More...
 
const_iterator begin () const
 Return an const_iterator to begin traversing the UPtrList. More...
 
const_iterator end () const
 Return an const_iterator to end traversing the UPtrList. More...
 
template<class T2 >
Foam::UPtrList< T2 > convert ()
 
template<class T2 >
Foam::UPtrList< const T2 > convert () const
 

Protected Member Functions

template<class INew >
void read (Istream &, const INew &inewt)
 Read from Istream using given Istream constructor class. More...
 

Friends

Istreamoperator>> (Istream &, PtrList< T > &)
 Read PtrList from Istream, discarding contents of existing PtrList. More...
 

Additional Inherited Members

- Public Types inherited from UPtrList< T >
typedef T value_type
 Type of values the UPtrList contains. More...
 
typedef Treference
 Type that can be used for storing into UPtrList::value_type objects. More...
 
typedef const Tconst_reference
 Type that can be used for storing into constant UPtrList::value_type. More...
 

Detailed Description

template<class T>
class Foam::PtrList< T >

A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used for subscript bounds checking, etc.

The element operator [] returns a reference to the object rather than a pointer.

Source files

Definition at line 72 of file PtrList.H.

Constructor & Destructor Documentation

◆ PtrList() [1/9]

Null Constructor.

Definition at line 32 of file PtrList.C.

◆ PtrList() [2/9]

PtrList ( const label  s)
explicit

Construct with size specified.

Definition at line 39 of file PtrList.C.

◆ PtrList() [3/9]

PtrList ( const PtrList< T > &  a)

Copy constructor.

Definition at line 46 of file PtrList.C.

References Foam::clone(), and forAll.

Here is the call graph for this function:

◆ PtrList() [4/9]

PtrList ( const PtrList< T > &  a,
const CloneArg &  cloneArg 
)

Copy constructor with additional argument for clone.

Definition at line 59 of file PtrList.C.

References Foam::clone(), and forAll.

Here is the call graph for this function:

◆ PtrList() [5/9]

PtrList ( PtrList< T > &&  lst)

Move constructor.

Definition at line 71 of file PtrList.C.

◆ PtrList() [6/9]

PtrList ( PtrList< T > &  a,
bool  reuse 
)

Construct as copy or reuse as specified.

Definition at line 78 of file PtrList.C.

References Foam::clone(), and forAll.

Here is the call graph for this function:

◆ PtrList() [7/9]

PtrList ( const SLPtrList< T > &  sll)
explicit

Construct as copy of SLPtrList<T>

Definition at line 93 of file PtrList.C.

◆ PtrList() [8/9]

PtrList ( Istream is,
const INew inewt 
)

Construct from Istream using given Istream constructor class.

Definition at line 160 of file PtrListIO.C.

References Foam::blockMeshTools::read().

Here is the call graph for this function:

◆ PtrList() [9/9]

PtrList ( Istream is)

Construct from Istream using default Istream constructor class.

Definition at line 167 of file PtrListIO.C.

References Foam::blockMeshTools::read().

Here is the call graph for this function:

◆ ~PtrList()

Destructor.

Definition at line 116 of file PtrList.C.

References forAll.

Member Function Documentation

◆ read()

void read ( Istream is,
const INew inewt 
)
protected

Read from Istream using given Istream constructor class.

Definition at line 36 of file PtrListIO.C.

References IOstream::fatalCheck(), forAll, token::isLabel(), token::labelToken(), Istream::readBeginList(), s(), setSize(), and Foam::T().

Referenced by IOPtrList< Type >::IOPtrList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSize()

◆ resize()

void resize ( const label  newSize)
inline

Alias for setSize(const label)

Definition at line 32 of file PtrListI.H.

References setSize().

Referenced by sampledSurfaces::sampleType(), and patchInjectionBase::topoChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shrink()

void shrink

Shrink the allocated space to the number of elements used.

Definition at line 174 of file PtrList.C.

◆ clear()

◆ append() [1/3]

void append ( T ptr)
inline

Append an element at the end of the list.

Definition at line 39 of file PtrListI.H.

References setSize().

Referenced by singleProcessorFaceSetsConstraint::add(), phaseSystem::generateInterfacialModels(), rigidBodyMeshMotion::rigidBodyMeshMotion(), rigidBodyMeshMotionSolver::rigidBodyMeshMotionSolver(), and domainDecomposition::writeProcs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append() [2/3]

void append ( const autoPtr< T > &  aptr)
inline

Append an element at the end of the list.

Definition at line 48 of file PtrListI.H.

◆ append() [3/3]

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

Append an element at the end of the list.

Definition at line 55 of file PtrListI.H.

◆ transfer()

void transfer ( PtrList< T > &  a)

Transfer the contents of the argument PtrList into this PtrList.

and annul the argument list

Definition at line 213 of file PtrList.C.

References clear().

Referenced by massFractions::execute(), fieldAverage::read(), IATE::read(), and conformedFvsPatchField< Type >::unconform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [1/4]

bool set ( const label  i) const
inline

Is element set.

Definition at line 62 of file PtrListI.H.

Referenced by fvMeshAdder::add(), Foam::addField(), BlendedInterfacialModel< ModelType >::BlendedInterfacialModel(), repatchMesh::changePatchType(), Foam::meshCheck::checkGeometry(), Foam::meshCheck::checkTopology(), conformedFvsPatchField< Type >::conform(), conformedFvPatchField< Type >::conform(), phaseSystem::correctContinuityError(), phaseSystem::correctPhi(), MomentumTransferPhaseSystem< BasePhaseSystem >::ddtCorrs(), repatchMesh::deletePatch(), MomentumTransferPhaseSystem< BasePhaseSystem >::dragCorrs(), massFractions::execute(), GAMGSolver::GAMGSolver(), lduPrimitiveMesh::gather(), phaseSystem::generateInterfacialModels(), surfaceZonesInfo::getAllClosedNamedSurfaces(), surfaceZonesInfo::getClosedNamedSurfaces(), surfaceZonesInfo::getInsidePointNamedSurfaces(), surfaceZonesInfo::getNamedSurfaces(), surfaceZonesInfo::getUnclosedNamedSurfaces(), GAMGProcAgglomeration::globalCellCells(), InjectionModel< CloudType >::inject(), InjectionModel< CloudType >::injectSteadyState(), singleCellFvMesh::interpolate(), fvMeshSubset::interpolate(), MomentumTransferPhaseSystem< BasePhaseSystem >::invADVfs(), MomentumTransferPhaseSystem< BasePhaseSystem >::invADVs(), Foam::MULES::limitSum(), LUscalarMatrix::LUscalarMatrix(), FieldField< Field, Type >::NewCalculatedType(), Foam::operator&(), pointBoundaryMesh::pointBoundaryMesh(), polyMesh::polyMesh(), compressibleMultiphaseVoF::pressureCorrector(), repatchMesh::read(), Maxwell< BasicMomentumTransportModel >::readModeCoefficients(), ensightParts::recalculate(), refinementSurfaces::refinementSurfaces(), refinementFeatures::regionEdgeTrees(), polyBoundaryMesh::renamePatches(), polyBoundaryMesh::reorderPatches(), pointBoundaryMesh::reset(), LduMatrix< Type, DType, LUType >::residual(), lduMatrix::residual(), sampledSets::sampleLocalType(), sampledSurfaces::sampleLocalType(), sampledSets::sampleType(), sampledSurfaces::sampleType(), PtrListDictionary< T >::set(), InjectionModel< CloudType >::setNumberOfParticles(), SidedInterfacialModel< blendedDiffusiveMassTransferModel >::SidedInterfacialModel(), SidedInterfacialModel< ModelType >::SidedInterfacialModel(), TGaussSeidelSmoother< Type, DType, LUType >::smooth(), phaseSystem::solve(), meshToMesh::srcPatchStabilisation(), fvMeshToFvMesh::srcToTgt(), subCycleFields< GeometricField >::subCycleFields(), meshToMesh::tgtPatchStabilisation(), conformedFvsPatchField< Type >::unconform(), conformedFvPatchField< Type >::unconform(), Foam::blendedInterfacialModel::valid(), multiValveEngine::valveList::valveList(), populationBalanceSizeDistribution::write(), OFstreamCollator::write(), domainDecomposition::writeComplete(), multicomponentThermo::implementation::Yslicer(), and psiuMulticomponentThermo::implementation::Yslicer().

Here is the caller graph for this function:

◆ set() [2/4]

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

Set element to given T* and return old element (can be nullptr)

Definition at line 69 of file PtrListI.H.

◆ set() [3/4]

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

Set element to given autoPtr<T> and return old element.

Definition at line 78 of file PtrListI.H.

◆ set() [4/4]

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

Set element to given tmp<T> and return old element.

Definition at line 89 of file PtrListI.H.

◆ reorder()

void reorder ( const labelUList oldToNew)

Reorders elements. Ordering does not have to be done in.

ascending or descending order. Reordering has to be unique. (is shuffle)

Definition at line 221 of file PtrList.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::name(), Foam::nl, UList< T >::size(), and Foam::T().

Referenced by polyBoundaryMesh::reorderPatches().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shuffle()

void shuffle ( const labelUList newToOld)

Reorders elements. Ordering does not have to be done in.

ascending or descending order. Reordering has to be unique. Note: can create unset elements

Definition at line 272 of file PtrList.C.

References clear(), forAll, UList< T >::size(), and Foam::T().

Referenced by polyBoundaryMesh::reorderPatches(), fvBoundaryMesh::shuffle(), and pointBoundaryMesh::shuffle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const PtrList< T > &  a)

Assignment operator.

Definition at line 298 of file PtrList.C.

References Foam::abort(), Foam::clone(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::name(), setSize(), UPtrList< T >::size(), and Foam::T().

Here is the call graph for this function:

◆ operator=() [2/2]

void operator= ( PtrList< T > &&  a)

Move assignment operator.

Definition at line 334 of file PtrList.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::T().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream ,
PtrList< T > &   
)
friend

Read PtrList from Istream, discarding contents of existing PtrList.


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