DynamicField< T, SizeMin > Class Template Reference

Dynamically sized Field. More...

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

Public Member Functions

constexpr DynamicField () noexcept
 Default construct, an empty field without allocation. More...
 
 DynamicField (const label len)
 Construct empty field with given reserve size. More...
 
 DynamicField (const label len, const T &val)
 Construct given size and initial value. More...
 
 DynamicField (const label len, const Foam::zero)
 Construct given size and initial value of zero. More...
 
 DynamicField (const DynamicField< T, SizeMin > &list)
 Copy construct. More...
 
template<int AnySizeMin>
 DynamicField (const DynamicField< T, AnySizeMin > &list)
 Copy construct with different sizing parameters. More...
 
 DynamicField (const UList< T > &list)
 Copy construct from UList. Size set to UList size. More...
 
template<class Addr >
 DynamicField (const IndirectListBase< T, Addr > &list)
 Copy construct from IndirectList. More...
 
 DynamicField (List< T > &&content)
 Move construct from List contents. More...
 
 DynamicField (DynamicField< T, SizeMin > &&content)
 Move construct from dynamic Field contents. More...
 
template<int AnySizeMin>
 DynamicField (DynamicField< T, AnySizeMin > &&content)
 Move construct with different sizing parameters. More...
 
template<int AnySizeMin>
 DynamicField (DynamicList< T, AnySizeMin > &&list)
 Move construct from DynamicList. More...
 
 DynamicField (const UList< T > &mapF, const labelUList &mapAddressing)
 Construct by 1 to 1 mapping from the given field. More...
 
 DynamicField (const UList< T > &mapF, const labelListList &mapAddressing, const scalarListList &weights)
 Construct by interpolative mapping from the given field. More...
 
 DynamicField (const UList< T > &mapF, const FieldMapper &map)
 Construct by mapping from the given field. More...
 
 DynamicField (Istream &is)
 Construct from Istream. Size set to size of list read. More...
 
tmp< DynamicField< T, SizeMin > > clone () const
 Clone. More...
 
label capacity () const noexcept
 Size of the underlying storage. More...
 
std::streamsize capacity_bytes () const noexcept
 Number of contiguous bytes of the underlying storage. More...
 
void setCapacity (const label len)
 Alter the size of the underlying storage. More...
 
void setCapacity_nocopy (const label len)
 
void setCapacity_unsafe (const label len) noexcept
 
void reserve (const label len)
 
void reserve_nocopy (const label len)
 
void resize (const label len)
 
void resize (const label len, const T &val)
 Alter addressable size and fill new space with constant value. More...
 
void resize_nocopy (const label len)
 
void setSize (const label n)
 Alias for resize() More...
 
void setSize (const label n, const T &val)
 Alias for resize() More...
 
void clear () noexcept
 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 shrinkStorage ()
 Shrink the allocated space to the number of elements used. More...
 
DynamicField< T, SizeMin > & shrink ()
 Shrink the allocated space to the number of elements used. More...
 
template<int AnySizeMin>
void swap (DynamicField< T, AnySizeMin > &other)
 Swap content, independent of sizing parameter. More...
 
template<int AnySizeMin>
void swap (DynamicList< T, AnySizeMin > &other)
 Swap content with DynamicList, independent of sizing parameter. More...
 
void transfer (List< T > &list)
 Transfer the parameter contents into this. More...
 
template<int AnySizeMin>
void transfer (DynamicList< T, AnySizeMin > &list)
 Transfer the parameter contents into this. More...
 
template<int AnySizeMin>
void transfer (DynamicField< T, AnySizeMin > &list)
 Transfer the parameter contents into this. More...
 
DynamicField< T, SizeMin > & append (const T &val)
 Append an element at the end of the list. More...
 
DynamicField< T, SizeMin > & append (T &&val)
 Move append an element. More...
 
DynamicField< T, SizeMin > & append (const UList< T > &list)
 Append a List at the end of this list. More...
 
T remove ()
 Remove and return the top element. More...
 
IstreamreadList (Istream &is)
 Read from Istream, discarding existing contents. More...
 
Toperator() (const label i)
 Return non-const access to an element, resizing list if needed. More...
 
void operator= (const T &val)
 Assign addressed entries to the given value. More...
 
void operator= (const Foam::zero)
 Assign addressed entries to zero. More...
 
void operator= (const UList< T > &list)
 Copy assignment. More...
 
void operator= (const DynamicField< T, SizeMin > &list)
 Copy assignment. More...
 
void operator= (List< T > &&list)
 Move assignment. More...
 
template<int AnySizeMin>
void operator= (DynamicList< T, AnySizeMin > &&list)
 Move assignment. More...
 
void operator= (DynamicField< T, SizeMin > &&list)
 Move assignment. More...
 
template<int AnySizeMin>
void operator= (DynamicField< T, AnySizeMin > &&list)
 Move assignment. More...
 

Static Public Member Functions

static const DynamicField< T, SizeMin > & null ()
 Return a null field. More...
 
static constexpr label min_size () noexcept
 Normal lower capacity limit - the SizeMin template parameter. More...
 

Friends

Istreamoperator>> (Istream &is, DynamicField< T, SizeMin > &rhs)
 Use the readList() method to read contents from Istream. More...
 
Ostreamoperator (Ostream &os, const DynamicField< T, SizeMin > &rhs)
 Write to Ostream. More...
 

Detailed Description

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

Dynamically sized Field.

Source files

Definition at line 49 of file DynamicField.H.

Constructor & Destructor Documentation

◆ DynamicField() [1/16]

constexpr DynamicField ( )
inlineconstexprnoexcept

Default construct, an empty field without allocation.

Definition at line 132 of file DynamicFieldI.H.

◆ DynamicField() [2/16]

DynamicField ( const label  len)
inlineexplicit

Construct empty field with given reserve size.

Definition at line 140 of file DynamicFieldI.H.

◆ DynamicField() [3/16]

DynamicField ( const label  len,
const T val 
)
inline

Construct given size and initial value.

Definition at line 151 of file DynamicFieldI.H.

◆ DynamicField() [4/16]

DynamicField ( const label  len,
const Foam::zero   
)
inline

Construct given size and initial value of zero.

Definition at line 163 of file DynamicFieldI.H.

◆ DynamicField() [5/16]

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

Copy construct.

Definition at line 175 of file DynamicFieldI.H.

◆ DynamicField() [6/16]

DynamicField ( const DynamicField< T, AnySizeMin > &  list)
inline

Copy construct with different sizing parameters.

Definition at line 187 of file DynamicFieldI.H.

◆ DynamicField() [7/16]

DynamicField ( const UList< T > &  list)
inlineexplicit

Copy construct from UList. Size set to UList size.

Also constructs from DynamicField with different sizing parameters.

Definition at line 198 of file DynamicFieldI.H.

◆ DynamicField() [8/16]

DynamicField ( const IndirectListBase< T, Addr > &  list)
inlineexplicit

Copy construct from IndirectList.

Definition at line 210 of file DynamicFieldI.H.

◆ DynamicField() [9/16]

DynamicField ( List< T > &&  content)
inlineexplicit

Move construct from List contents.

Definition at line 221 of file DynamicFieldI.H.

◆ DynamicField() [10/16]

DynamicField ( DynamicField< T, SizeMin > &&  content)
inline

Move construct from dynamic Field contents.

Definition at line 246 of file DynamicFieldI.H.

◆ DynamicField() [11/16]

DynamicField ( DynamicField< T, AnySizeMin > &&  content)
inline

Move construct with different sizing parameters.

Definition at line 260 of file DynamicFieldI.H.

◆ DynamicField() [12/16]

DynamicField ( DynamicList< T, AnySizeMin > &&  list)
inline

Move construct from DynamicList.

Definition at line 233 of file DynamicFieldI.H.

◆ DynamicField() [13/16]

DynamicField ( const UList< T > &  mapF,
const labelUList mapAddressing 
)
inline

Construct by 1 to 1 mapping from the given field.

Definition at line 273 of file DynamicFieldI.H.

◆ DynamicField() [14/16]

DynamicField ( const UList< T > &  mapF,
const labelListList mapAddressing,
const scalarListList weights 
)
inline

Construct by interpolative mapping from the given field.

Definition at line 285 of file DynamicFieldI.H.

◆ DynamicField() [15/16]

DynamicField ( const UList< T > &  mapF,
const FieldMapper map 
)
inline

Construct by mapping from the given field.

Definition at line 298 of file DynamicFieldI.H.

◆ DynamicField() [16/16]

DynamicField ( Istream is)
inlineexplicit

Construct from Istream. Size set to size of list read.

Definition at line 309 of file DynamicFieldI.H.

Member Function Documentation

◆ null()

static const DynamicField<T, SizeMin>& null ( )
inlinestatic

Return a null field.

Definition at line 100 of file DynamicField.H.

◆ clone()

Foam::tmp< Foam::DynamicField< T, SizeMin > > clone ( ) const
inline

Clone.

Definition at line 318 of file DynamicFieldI.H.

◆ min_size()

static constexpr label min_size ( )
inlinestaticconstexprnoexcept

Normal lower capacity limit - the SizeMin template parameter.

Definition at line 183 of file DynamicField.H.

◆ capacity()

Foam::label capacity ( ) const
inlinenoexcept

Size of the underlying storage.

Definition at line 327 of file DynamicFieldI.H.

Referenced by extendedEdgeMesh::cut(), and DynamicField< Foam::Vector >::transfer().

Here is the caller graph for this function:

◆ capacity_bytes()

std::streamsize capacity_bytes ( ) const
inlinenoexcept

Number of contiguous bytes of the underlying storage.

Note
Only meaningful for contiguous data

Definition at line 335 of file DynamicFieldI.H.

◆ setCapacity()

void setCapacity ( const label  len)
inline

Alter the size of the underlying storage.

The addressed size will be truncated if needed to fit, but will remain otherwise untouched. Use this or reserve() in combination with append().

Definition at line 343 of file DynamicFieldI.H.

Referenced by extendedEdgeMesh::cut().

Here is the caller graph for this function:

◆ setCapacity_nocopy()

void setCapacity_nocopy ( const label  len)
inline

Alter the size of the underlying storage, without retaining old content.

The addressed size will be truncated if needed to fit, but will remain otherwise untouched.

Definition at line 353 of file DynamicFieldI.H.

◆ setCapacity_unsafe()

void setCapacity_unsafe ( const label  len)
inlinenoexcept

Change the value for the list capacity directly (ADVANCED, UNSAFE) Does not perform any memory management or resizing.

Definition at line 363 of file DynamicFieldI.H.

◆ reserve()

void reserve ( const label  len)
inline

Reserve allocation space for at least this size, allocating new space if required and retaining old content.

Never shrinks the allocated size, use setCapacity() for that.

Definition at line 373 of file DynamicFieldI.H.

◆ reserve_nocopy()

void reserve_nocopy ( const label  len)
inline

Reserve allocation space for at least this size, allocating new space if required without retaining old content.

Never shrinks the allocated size, use setCapacity() for that.

Definition at line 383 of file DynamicFieldI.H.

◆ resize() [1/2]

void resize ( const label  len)
inline

Alter addressable list size, allocating new space if required while recovering old content.

If no reallocation is required, the contents remain untouched. Otherwise new entries will be uninitialized. Use this to resize the list prior to using the operator[] for setting values (as per List usage).

Definition at line 393 of file DynamicFieldI.H.

Referenced by DynamicField< Foam::Vector >::setSize().

Here is the caller graph for this function:

◆ resize() [2/2]

void resize ( const label  len,
const T val 
)
inline

Alter addressable size and fill new space with constant value.

Definition at line 413 of file DynamicFieldI.H.

◆ resize_nocopy()

void resize_nocopy ( const label  len)
inline

Alter addressable list size, allocating new space if required without necessarily recovering old content.

If no reallocation is required, the contents remain untouched. Otherwise all entries will be uninitialized.

Definition at line 403 of file DynamicFieldI.H.

◆ setSize() [1/2]

void setSize ( const label  n)
inline

Alias for resize()

Definition at line 239 of file DynamicField.H.

◆ setSize() [2/2]

void setSize ( const label  n,
const T val 
)
inline

Alias for resize()

Definition at line 242 of file DynamicField.H.

◆ clear()

void clear ( )
inlinenoexcept

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

Allocated size does not change

Definition at line 431 of file DynamicFieldI.H.

Referenced by isoAlpha::reconstruct().

Here is the caller graph for this function:

◆ clearStorage()

void clearStorage ( )
inline

Clear the list and delete storage.

Definition at line 438 of file DynamicFieldI.H.

Referenced by zoneDistribute::getFields(), and DynamicField< Foam::Vector >::transfer().

Here is the caller graph for this function:

◆ expandStorage()

Foam::label expandStorage ( )
inlinenoexcept

Expand the addressable size to fit the allocated capacity.

Returns the previous addressable size.

Definition at line 446 of file DynamicFieldI.H.

◆ shrinkStorage()

void shrinkStorage ( )
inline

Shrink the allocated space to the number of elements used.

Definition at line 458 of file DynamicFieldI.H.

◆ shrink()

Foam::DynamicField< T, SizeMin > & shrink ( )
inline

Shrink the allocated space to the number of elements used.

Returns a reference to the DynamicField.

Definition at line 475 of file DynamicFieldI.H.

◆ swap() [1/2]

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

Swap content, independent of sizing parameter.

Definition at line 485 of file DynamicFieldI.H.

◆ swap() [2/2]

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

Swap content with DynamicList, independent of sizing parameter.

Definition at line 506 of file DynamicFieldI.H.

◆ transfer() [1/3]

void transfer ( List< T > &  list)
inline

Transfer the parameter contents into this.

Definition at line 532 of file DynamicFieldI.H.

◆ transfer() [2/3]

void transfer ( DynamicList< T, AnySizeMin > &  list)
inline

Transfer the parameter contents into this.

Definition at line 543 of file DynamicFieldI.H.

◆ transfer() [3/3]

void transfer ( DynamicField< T, AnySizeMin > &  list)
inline

Transfer the parameter contents into this.

Definition at line 565 of file DynamicFieldI.H.

◆ append() [1/3]

Foam::DynamicField< T, SizeMin > & append ( const T val)
inline

Append an element at the end of the list.

Definition at line 587 of file DynamicFieldI.H.

Referenced by extendedEdgeMesh::add(), extendedEdgeMesh::cut(), zoneDistribute::getFields(), and isoAlpha::reconstruct().

Here is the caller graph for this function:

◆ append() [2/3]

Foam::DynamicField< T, SizeMin > & append ( T &&  val)
inline

Move append an element.

Definition at line 602 of file DynamicFieldI.H.

◆ append() [3/3]

Foam::DynamicField< T, SizeMin > & append ( const UList< T > &  list)
inline

Append a List at the end of this list.

Definition at line 617 of file DynamicFieldI.H.

◆ remove()

T remove ( )
inline

Remove and return the top element.

Definition at line 640 of file DynamicFieldI.H.

◆ readList()

Foam::Istream & readList ( Istream is)
inline

Read from Istream, discarding existing contents.

Uses a DynamicList::readList internally

Definition at line 767 of file DynamicFieldI.H.

◆ operator()()

T & operator() ( const label  i)
inline

Return non-const access to an element, resizing list if needed.

Definition at line 663 of file DynamicFieldI.H.

◆ operator=() [1/8]

void operator= ( const T val)
inline

Assign addressed entries to the given value.

Definition at line 678 of file DynamicFieldI.H.

◆ operator=() [2/8]

void operator= ( const Foam::zero  )
inline

Assign addressed entries to zero.

Definition at line 688 of file DynamicFieldI.H.

◆ operator=() [3/8]

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

Copy assignment.

Definition at line 698 of file DynamicFieldI.H.

◆ operator=() [4/8]

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

Copy assignment.

Definition at line 708 of file DynamicFieldI.H.

◆ operator=() [5/8]

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

Move assignment.

Definition at line 723 of file DynamicFieldI.H.

◆ operator=() [6/8]

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

Move assignment.

Definition at line 755 of file DynamicFieldI.H.

◆ operator=() [7/8]

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

Move assignment.

Definition at line 733 of file DynamicFieldI.H.

◆ operator=() [8/8]

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

Move assignment.

Definition at line 744 of file DynamicFieldI.H.

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream is,
DynamicField< T, SizeMin > &  rhs 
)
friend

Use the readList() method to read contents from Istream.

◆ operator

Ostream& operator ( Ostream os,
const DynamicField< T, SizeMin > &  rhs 
)
friend

Write to Ostream.


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