PSCF v1.3
Util::PArray< Data > Class Template Reference

An array that only holds pointers to its elements. More...

#include <PArray.h>

Inheritance diagram for Util::PArray< Data >:
Util::ArraySet< Data > Util::DPArray< Data > Util::GPArray< Data >

Public Member Functions

virtual ~PArray ()
 Destructor.
int capacity () const
 Return allocated size.
int size () const
 Return logical size.
void begin (PArrayIterator< Data > &iterator) const
 Set a PArrayIterator to the beginning of this PArray.
void begin (ConstPArrayIterator< Data > &iterator) const
 Set a ConstPArrayIterator to the beginning of this PArray.
Data & operator[] (int i) const
 Mimic C array subscripting.

Protected Member Functions

 PArray ()
 Constructor (protected to prevent instantiation).

Protected Attributes

Data ** ptrs_
 PArray of of pointers to Data objects.
int capacity_
 Allocated size of ptrs_ array.
int size_
 Logical size (number of elements with initialized data).

Detailed Description

template<typename Data>
class Util::PArray< Data >

An array that only holds pointers to its elements.

A PArray<Data> is an array that is implemented by storing pointers to Data objects, rather than actual Data objects. The array suscript operator [] returns a reference to an associated Data object, as for Array<Data>. A PArray<Data> is not responsible for destroying the associated Data objects.

A PArray<Data> object has a logical size and physical capacity. The logical size grows as pointers to objects are appended.

A PArray cannot be instantiated, because its constructor is protected. PArray is a base class for DPArray and for ArraySet.

Definition at line 36 of file PArray.h.

Constructor & Destructor Documentation

◆ ~PArray()

template<typename Data>
Util::PArray< Data >::~PArray ( )
virtual

Destructor.

Definition at line 126 of file PArray.h.

◆ PArray()

template<typename Data>
Util::PArray< Data >::PArray ( )
inlineprotected

Constructor (protected to prevent instantiation).

Definition at line 116 of file PArray.h.

References capacity_, ptrs_, and size_.

Referenced by Util::DPArray< Data >::DPArray(), Util::DPArray< Data >::DPArray(), Util::GPArray< Data >::GPArray(), and Util::GPArray< Data >::GPArray().

Member Function Documentation

◆ capacity()

template<typename Data>
int Util::PArray< Data >::capacity ( ) const
inline

Return allocated size.

Returns
Number of elements allocated in array.

Definition at line 133 of file PArray.h.

References capacity_.

Referenced by Util::ArraySet< Data >::allocate(), Util::DPArray< Data >::allocate(), and Util::GPArray< Data >::reserve().

◆ size()

template<typename Data>
int Util::PArray< Data >::size ( ) const
inline

Return logical size.

Returns
logical size of this array.

Definition at line 140 of file PArray.h.

References size_.

Referenced by Util::ArraySet< Data >::isValid().

◆ begin() [1/2]

template<typename Data>
void Util::PArray< Data >::begin ( PArrayIterator< Data > & iterator) const
inline

Set a PArrayIterator to the beginning of this PArray.

Parameters
iteratorPArrayIterator, initialized on output.

Definition at line 147 of file PArray.h.

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

◆ begin() [2/2]

template<typename Data>
void Util::PArray< Data >::begin ( ConstPArrayIterator< Data > & iterator) const
inline

Set a ConstPArrayIterator to the beginning of this PArray.

Parameters
iteratorPArrayIterator, initialized on output.

Definition at line 162 of file PArray.h.

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

◆ operator[]()

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

Mimic C array subscripting.

Parameters
iarray index
Returns
reference to element i

Definition at line 176 of file PArray.h.

References ptrs_, and size_.

Member Data Documentation

◆ ptrs_

◆ capacity_

◆ size_


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