UPtrList< T > Class Template Reference

A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers - this is to be done elsewhere. The operator[] returns a reference to the object, not the pointer. More...

Inheritance diagram for UPtrList< T >:
[legend]
Collaboration diagram for UPtrList< T >:
[legend]

Classes

class  const_iterator
 Random-access iterator with const access. More...
 
class  iterator
 Random-access iterator with non-const access. More...
 

Public Types

typedef T value_type
 Type of values the list contains. More...
 
typedef Treference
 A non-const reference to the value_type. More...
 

Public Member Functions

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. 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...
 
Tget (const label i)
 Return pointer to element (can be nullptr),. More...
 
const Tget (const label i) const
 Return const pointer to element (can be nullptr),. More...
 
const Tset (const label i) const
 Return const pointer to element (can be nullptr),. More...
 
void clear ()
 Set list size to zero. More...
 
void resize (const label newLen)
 Reset size of list. More...
 
void setSize (const label newLen)
 Same as 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 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 testNull=true)
 
void sortOrder (const labelUList &order, const bool testNull=true)
 
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...
 
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...
 

Public Attributes

const typedef Tconst_reference
 A const reference to the value_type. More...
 

Protected Member Functions

 UPtrList (Detail::PtrListDetail< T > &&ptrs)
 Low-level move construct. More...
 

Protected Attributes

Detail::PtrListDetail< Tptrs_
 The list of pointers. More...
 

Friends

Ostreamoperator (Ostream &os, const UPtrList< T > &list)
 Write UPtrList to Ostream. More...
 

Detailed Description

template<class T>
class Foam::UPtrList< T >

A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers - this is to be done elsewhere. The operator[] returns a reference to the object, not the pointer.

Note
The class definition is such that it contains a list of pointers, but itself does not inherit from a list of pointers since this would wreak havoc later with inheritance resolution.
See also
Foam::PtrList Foam::PtrDynList
Source files

Definition at line 62 of file UPtrList.H.

Member Typedef Documentation

◆ value_type

typedef T value_type

Type of values the list contains.

Definition at line 91 of file UPtrList.H.

◆ reference

typedef T& reference

A non-const reference to the value_type.

Definition at line 94 of file UPtrList.H.

Constructor & Destructor Documentation

◆ UPtrList() [1/9]

UPtrList ( Detail::PtrListDetail< T > &&  ptrs)
inlineprotected

Low-level move construct.

Definition at line 46 of file UPtrListI.H.

◆ UPtrList() [2/9]

constexpr UPtrList ( )
inlineconstexprnoexcept

Default construct.

Definition at line 32 of file UPtrListI.H.

◆ UPtrList() [3/9]

UPtrList ( const label  len)
inlineexplicit

Construct with specified size, each element initialized to nullptr.

Definition at line 39 of file UPtrListI.H.

◆ UPtrList() [4/9]

UPtrList ( const UPtrList< T > &  list)
inline

Copy construct (shallow copies addresses)

Definition at line 53 of file UPtrListI.H.

◆ UPtrList() [5/9]

UPtrList ( UPtrList< T > &&  list)
inline

Move construct.

Definition at line 60 of file UPtrListI.H.

◆ UPtrList() [6/9]

UPtrList ( UPtrList< T > &  list,
bool  reuse 
)
inline

Construct as shallow copy or re-use as specified.

Definition at line 67 of file UPtrListI.H.

◆ UPtrList() [7/9]

UPtrList ( PtrList< T > &  list)
explicit

Shallow copy from PtrList.

The argument is non-const to reflect that the UPtrList can change the values (not the addresses) within the original list.

Definition at line 36 of file UPtrList.C.

◆ UPtrList() [8/9]

UPtrList ( const UList< T * > &  list)
inlineexplicit

Construct from UList of pointers.

Definition at line 74 of file UPtrListI.H.

◆ UPtrList() [9/9]

UPtrList ( UList< T > &  list)
inlineexplicit

Construct from UList, taking the address of each list element.

The argument is non-const to reflect that the UPtrList can change the values of the original list.

Definition at line 81 of file UPtrListI.H.

Member Function Documentation

◆ size()

◆ empty()

bool empty ( ) const
inlinenoexcept

True if the list is empty (ie, size() is zero)

Definition at line 104 of file UPtrListI.H.

◆ first() [1/2]

T & first ( )
inline

Return reference to the first element of the list.

Definition at line 146 of file UPtrListI.H.

◆ first() [2/2]

const T & first ( ) const
inline

Return reference to first element of the list.

Definition at line 153 of file UPtrListI.H.

◆ last() [1/2]

T & last ( )
inline

Return reference to the last element of the list.

Definition at line 160 of file UPtrListI.H.

◆ last() [2/2]

const T & last ( ) const
inline

Return reference to the last element of the list.

Definition at line 167 of file UPtrListI.H.

◆ get() [1/2]

T * get ( const label  i)
inline

Return pointer to element (can be nullptr),.

without bounds checking.

Definition at line 111 of file UPtrListI.H.

◆ get() [2/2]

const T * get ( const label  i) const
inline

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

without bounds checking.

Definition at line 118 of file UPtrListI.H.

◆ set() [1/2]

◆ clear()

void clear ( )
inline

Set list size to zero.

Definition at line 125 of file UPtrListI.H.

◆ resize()

void resize ( const label  newLen)
inline

Reset size of list.

New entries are initialized to nullptr.

Definition at line 174 of file UPtrListI.H.

◆ setSize()

void setSize ( const label  newLen)
inline

Same as resize()

Definition at line 181 of file UPtrListI.H.

Referenced by dynamicOversetFvMesh::updateAddressing().

Here is the caller graph for this function:

◆ squeezeNull()

Foam::label squeezeNull ( )

Squeeze out intermediate nullptr entries in the list of pointers.

Returns
the number of non-null entries

Definition at line 45 of file UPtrList.C.

◆ append()

void append ( T ptr)
inline

Append an element to the end of the list.

Definition at line 188 of file UPtrListI.H.

◆ swap()

void swap ( UPtrList< T > &  list)
inline

Swap content.

Definition at line 132 of file UPtrListI.H.

◆ transfer()

void transfer ( UPtrList< T > &  list)
inline

Transfer contents into this list and annul the argument.

Definition at line 139 of file UPtrListI.H.

Referenced by wallDistData< TransferType >::correct(), meshWave::correct(), and directionalMeshWave::correct().

Here is the caller graph for this function:

◆ set() [2/2]

T * set ( const label  i,
T ptr 
)
inline

Set element to specified pointer and return the old list element, which can be a nullptr.

No-op if the new pointer value is identical to the current content.

Definition at line 197 of file UPtrListI.H.

◆ reorder()

void reorder ( const labelUList oldToNew,
const bool  testNull = true 
)

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

Optionally verify that all pointers have been set.

Definition at line 70 of file UPtrList.C.

◆ sortOrder()

void sortOrder ( const labelUList order,
const bool  testNull = true 
)

Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie, shuffle).

Optionally verify that all pointers have been set.

Definition at line 129 of file UPtrList.C.

Referenced by Foam::shuffle(), and Foam::sort().

Here is the caller graph for this function:

◆ operator[]() [1/2]

const T & operator[] ( const label  i) const
inline

Return const reference to the element.

Definition at line 212 of file UPtrListI.H.

◆ operator[]() [2/2]

T & operator[] ( const label  i)
inline

Return reference to the element.

Definition at line 229 of file UPtrListI.H.

◆ operator()()

const T * operator() ( const label  i) const
inline

Return const pointer to the element - same as get().

Definition at line 246 of file UPtrListI.H.

◆ operator=() [1/2]

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

Copy assignment (shallow copies addresses)

Definition at line 663 of file UPtrListI.H.

◆ operator=() [2/2]

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

Move assignment.

Definition at line 670 of file UPtrListI.H.

◆ begin() [1/2]

Foam::UPtrList< T >::iterator begin ( )
inline

Return an iterator to begin traversing the UPtrList.

Definition at line 614 of file UPtrListI.H.

◆ end() [1/2]

Foam::UPtrList< T >::iterator end ( )
inline

Return an iterator to end traversing the UPtrList.

Definition at line 622 of file UPtrListI.H.

◆ cbegin()

Foam::UPtrList< T >::const_iterator cbegin ( ) const
inline

Return an const_iterator to begin traversing the UPtrList.

Definition at line 630 of file UPtrListI.H.

◆ cend()

Foam::UPtrList< T >::const_iterator cend ( ) const
inline

Return an const_iterator to end traversing the UPtrList.

Definition at line 638 of file UPtrListI.H.

◆ begin() [2/2]

Foam::UPtrList< T >::const_iterator begin ( ) const
inline

Return an const_iterator to begin traversing the UPtrList.

Definition at line 646 of file UPtrListI.H.

◆ end() [2/2]

Foam::UPtrList< T >::const_iterator end ( ) const
inline

Return an const_iterator to end traversing the UPtrList.

Definition at line 654 of file UPtrListI.H.

Friends And Related Function Documentation

◆ operator

Ostream& operator ( Ostream os,
const UPtrList< T > &  list 
)
friend

Write UPtrList to Ostream.

Member Data Documentation

◆ const_reference

const typedef T& const_reference

A const reference to the value_type.

Definition at line 97 of file UPtrList.H.

◆ ptrs_


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