PSCF v1.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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. More...
 
int capacity () const
 Return allocated size. More...
 
int size () const
 Return logical size. More...
 
void begin (PArrayIterator< Data > &iterator) const
 Set a PArrayIterator to the beginning of this PArray. More...
 
void begin (ConstPArrayIterator< Data > &iterator) const
 Set a ConstPArrayIterator to the beginning of this PArray. More...
 
Data & operator[] (int i) const
 Mimic C array subscripting. More...
 

Protected Member Functions

 PArray ()
 Constructor (protected to prevent instantiation). More...
 

Protected Attributes

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

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.

Member Function Documentation

◆ capacity()

template<typename Data >
int Util::PArray< Data >::capacity
inline

Return allocated size.

Returns
Number of elements allocated in array.

Definition at line 133 of file PArray.h.

◆ size()

template<typename Data >
int Util::PArray< Data >::size
inline

Return logical size.

Returns
logical size of this array.

Definition at line 140 of file PArray.h.

Referenced by pscfpp.file.File::__eq__(), pscfpp.text.Record::__init__(), pscfpp.file.File::__init__(), pscfpp.file.File::__repr__(), and pscfpp.text.Record::__str__().

◆ 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 Util::PArrayIterator< Data >::setCurrent(), Util::PArrayIterator< Data >::setEnd(), and Util::PArrayIterator< Data >::setNull().

◆ 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 Util::ConstPArrayIterator< Data >::setCurrent(), Util::ConstPArrayIterator< Data >::setEnd(), and Util::ConstPArrayIterator< Data >::setNull().

◆ 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.

Member Data Documentation

◆ ptrs_

template<typename Data >
Data** Util::PArray< Data >::ptrs_
protected

PArray of of pointers to Data objects.

Definition at line 90 of file PArray.h.

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

◆ capacity_

template<typename Data >
int Util::PArray< Data >::capacity_
protected

Allocated size of ptrs_ array.

Definition at line 93 of file PArray.h.

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

◆ size_

template<typename Data >
int Util::PArray< Data >::size_
protected

Logical size (number of elements with initialized data).

Definition at line 96 of file PArray.h.

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


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