PSCF v1.1
Public Member Functions | Protected Attributes | List of all members
Util::FPArray< Data, Capacity > Class Template Reference

Statically allocated pointer array. More...

#include <FPArray.h>

Public Member Functions

 FPArray ()
 Default constructor. More...
 
 FPArray (FPArray< Data, Capacity > const &other)
 Copy constructor. More...
 
 ~FPArray ()
 Destructor. More...
 
FPArray< Data, Capacity > & operator= (FPArray< Data, Capacity > const &other)
 Assignment, element by element. More...
 
void append (Data &data)
 Append an element to the end of the array. More...
 
void clear ()
 Set logical size to zero and nullify all elements. More...
 
int capacity () const
 Return physical capacity of array. More...
 
int size () const
 Return logical size of this array. More...
 
void begin (PArrayIterator< Data > &iterator)
 Set an iterator to begin this container. More...
 
void begin (ConstPArrayIterator< Data > &iterator) const
 Set a const iterator to begin this container. More...
 
Data & operator[] (int i)
 Get an element by reference (mimic C-array subscripting). More...
 
Data const & operator[] (int i) const
 Get an element by const reference (mimic C-array subscripting). More...
 

Protected Attributes

Data * ptrs_ [Capacity]
 Array of pointers to Data objects. More...
 
int size_
 Logical size of array (number of elements used). More...
 

Detailed Description

template<typename Data, int Capacity>
class Util::FPArray< Data, Capacity >

Statically allocated pointer array.

A FPArray is a statically allocated array that actually holds pointers to Data objects, but for which the [] operator returns a reference to the associated object. It is implemented as a wrapper for a statically allocated C array of Data* pointers. A FPArray is not responsible for destroying the associated Data objects.

The interface of an FPArray is identical to that of an FSArray. An FPArray has both a capacity that is set at compile time, which is the physical size of the underlying C array, and a size, which is the number of contiguous elements (indexed from 0 to size-1) that contain valid pointers. The size can only be increased only by the append() method, which adds an element to the end of the array.

When compiled in debug mode, the operator [] checks that the index is less than the size and non-negative.

Definition at line 40 of file FPArray.h.

Constructor & Destructor Documentation

◆ FPArray() [1/2]

template<typename Data , int Capacity>
Util::FPArray< Data, Capacity >::FPArray
inline

Default constructor.

Constructor.

Definition at line 139 of file FPArray.h.

◆ FPArray() [2/2]

template<typename Data , int Capacity>
Util::FPArray< Data, Capacity >::FPArray ( FPArray< Data, Capacity > const &  other)

Copy constructor.

Copies all pointers.

Parameters
otherthe FPArray to be copied.

Definition at line 147 of file FPArray.h.

References Util::FPArray< Data, Capacity >::ptrs_, and Util::FPArray< Data, Capacity >::size_.

◆ ~FPArray()

template<typename Data , int Capacity>
Util::FPArray< Data, Capacity >::~FPArray

Destructor.

Definition at line 202 of file FPArray.h.

Member Function Documentation

◆ operator=()

template<typename Data , int Capacity>
FPArray< Data, Capacity > & Util::FPArray< Data, Capacity >::operator= ( FPArray< Data, Capacity > const &  other)

Assignment, element by element.

Parameters
otherthe rhs FPArray

Definition at line 171 of file FPArray.h.

References Util::FPArray< Data, Capacity >::size_, and UTIL_THROW.

◆ append()

template<typename Data , int Capacity>
void Util::FPArray< Data, Capacity >::append ( Data &  data)
inline

Append an element to the end of the array.

Parameters
dataData to add to end of array.

Definition at line 275 of file FPArray.h.

References UTIL_THROW.

◆ clear()

template<typename Data , int Capacity>
void Util::FPArray< Data, Capacity >::clear
inline

Set logical size to zero and nullify all elements.

Definition at line 288 of file FPArray.h.

◆ capacity()

template<typename Data , int Capacity>
int Util::FPArray< Data, Capacity >::capacity
inline

Return physical capacity of array.

Definition at line 209 of file FPArray.h.

◆ size()

template<typename Data , int Capacity>
int Util::FPArray< Data, Capacity >::size
inline

◆ begin() [1/2]

template<typename Data , int Capacity>
void Util::FPArray< Data, Capacity >::begin ( PArrayIterator< Data > &  iterator)
inline

Set an iterator to begin this container.

Parameters
iteratorPArrayIterator, initialized on output.

Definition at line 224 of file FPArray.h.

References Util::PArrayIterator< Data >::setCurrent(), and Util::PArrayIterator< Data >::setEnd().

◆ begin() [2/2]

template<typename Data , int Capacity>
void Util::FPArray< Data, Capacity >::begin ( ConstPArrayIterator< Data > &  iterator) const
inline

Set a const iterator to begin this container.

Parameters
iteratorConstPArrayIterator, initialized on output.

Definition at line 235 of file FPArray.h.

References Util::ConstPArrayIterator< Data >::setCurrent(), and Util::ConstPArrayIterator< Data >::setEnd().

◆ operator[]() [1/2]

template<typename Data , int Capacity>
Data & Util::FPArray< Data, Capacity >::operator[] ( int  i)
inline

Get an element by reference (mimic C-array subscripting).

Parameters
iarray index
Returns
reference to element i

Definition at line 248 of file FPArray.h.

◆ operator[]() [2/2]

template<typename Data , int Capacity>
Data const & Util::FPArray< Data, Capacity >::operator[] ( int  i) const
inline

Get an element by const reference (mimic C-array subscripting).

Parameters
iarray index
Returns
const reference to element i

Definition at line 262 of file FPArray.h.

Member Data Documentation

◆ ptrs_

template<typename Data , int Capacity>
Data* Util::FPArray< Data, Capacity >::ptrs_[Capacity]
protected

Array of pointers to Data objects.

Definition at line 126 of file FPArray.h.

Referenced by Util::FPArray< Data, Capacity >::FPArray().

◆ size_

template<typename Data , int Capacity>
int Util::FPArray< Data, Capacity >::size_
protected

Logical size of array (number of elements used).

Definition at line 129 of file FPArray.h.

Referenced by Util::FPArray< Data, Capacity >::FPArray(), and Util::FPArray< Data, Capacity >::operator=().


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