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)
 
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 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 () noexcept
 Return an iterator to begin traversing the UPtrList. More...
 
iterator end () noexcept
 Return an iterator to end traversing the UPtrList. More...
 
const_iterator cbegin () const noexcept
 Return an const_iterator to begin traversing the UPtrList. More...
 
const_iterator cend () const noexcept
 Return an const_iterator to end traversing the UPtrList. More...
 
const_iterator begin () const noexcept
 Return an const_iterator to begin traversing the UPtrList. More...
 
const_iterator end () const noexcept
 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

void setAddressableSize (const label n) noexcept
 Adjust addressable size. More...
 
 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 97 of file UPtrList.H.

◆ reference

typedef T& reference

A non-const reference to the value_type.

Definition at line 100 of file UPtrList.H.

Constructor & Destructor Documentation

◆ UPtrList() [1/9]

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

Low-level move construct.

Definition at line 55 of file UPtrListI.H.

◆ UPtrList() [2/9]

constexpr UPtrList ( )
inlineconstexprnoexcept

Default construct.

Definition at line 41 of file UPtrListI.H.

◆ UPtrList() [3/9]

UPtrList ( const label  len)
inlineexplicit

Construct with specified size, each element initialized to nullptr.

Definition at line 48 of file UPtrListI.H.

◆ UPtrList() [4/9]

UPtrList ( const UPtrList< T > &  list)
inline

Copy construct (shallow copies addresses)

Definition at line 62 of file UPtrListI.H.

◆ UPtrList() [5/9]

UPtrList ( UPtrList< T > &&  list)
inline

Move construct.

Definition at line 69 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 76 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 83 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 90 of file UPtrListI.H.

Member Function Documentation

◆ setAddressableSize()

void setAddressableSize ( const label  n)
inlineprotectednoexcept

Adjust addressable size.

Definition at line 32 of file UPtrListI.H.

◆ size()

◆ empty()

bool empty ( ) const
inlinenoexcept

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

Definition at line 113 of file UPtrListI.H.

◆ first() [1/2]

T & first ( )
inline

Return reference to the first element of the list.

Definition at line 155 of file UPtrListI.H.

◆ first() [2/2]

const T & first ( ) const
inline

Return reference to first element of the list.

Definition at line 162 of file UPtrListI.H.

◆ last() [1/2]

T & last ( )
inline

Return reference to the last element of the list.

Definition at line 169 of file UPtrListI.H.

◆ last() [2/2]

const T & last ( ) const
inline

Return reference to the last element of the list.

Definition at line 176 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 120 of file UPtrListI.H.

Referenced by fvMeshAdder::add().

Here is the caller graph for this function:

◆ 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 127 of file UPtrListI.H.

◆ set() [1/2]

◆ clear()

void clear ( )
inline

Set list size to zero.

Definition at line 134 of file UPtrListI.H.

◆ resize()

void resize ( const label  newLen)
inline

Change the size of the list.

New entries are initialized to nullptr.

Definition at line 183 of file UPtrListI.H.

Referenced by UPtrList< const Foam::UList >::setSize().

Here is the caller graph for this function:

◆ setSize()

void setSize ( const label  n)
inline

Alias for resize()

Definition at line 189 of file UPtrList.H.

Referenced by fvMatrix< Type >::setInterfaces(), and 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 190 of file UPtrListI.H.

◆ swap()

void swap ( UPtrList< T > &  list)
inline

Swap content.

Definition at line 141 of file UPtrListI.H.

◆ transfer()

void transfer ( UPtrList< T > &  list)
inline

Transfer contents into this list and annul the argument.

Definition at line 148 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 199 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 214 of file UPtrListI.H.

◆ operator[]() [2/2]

T & operator[] ( const label  i)
inline

Return reference to the element.

Definition at line 231 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 248 of file UPtrListI.H.

◆ operator=() [1/2]

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

Copy assignment (shallow copies addresses)

Definition at line 649 of file UPtrListI.H.

◆ operator=() [2/2]

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

Move assignment.

Definition at line 656 of file UPtrListI.H.

◆ begin() [1/2]

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

Return an iterator to begin traversing the UPtrList.

Definition at line 600 of file UPtrListI.H.

◆ end() [1/2]

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

Return an iterator to end traversing the UPtrList.

Definition at line 608 of file UPtrListI.H.

◆ cbegin()

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

Return an const_iterator to begin traversing the UPtrList.

Definition at line 616 of file UPtrListI.H.

◆ cend()

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

Return an const_iterator to end traversing the UPtrList.

Definition at line 624 of file UPtrListI.H.

◆ begin() [2/2]

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

Return an const_iterator to begin traversing the UPtrList.

Definition at line 632 of file UPtrListI.H.

◆ end() [2/2]

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

Return an const_iterator to end traversing the UPtrList.

Definition at line 640 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 103 of file UPtrList.H.

◆ ptrs_


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