PSCF v1.1
Public Member Functions | List of all members
Util::DPArray< Data > Class Template Reference

A dynamic array that only holds pointers to its elements. More...

#include <DPArray.h>

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

Public Member Functions

 DPArray ()
 Constructor. More...
 
 DPArray (DPArray< Data > const &other)
 Copy constructor, copy pointers. More...
 
virtual ~DPArray ()
 Destructor. More...
 
DPArray< Data > & operator= (DPArray< Data > const &other)
 Assignment, element by element. More...
 
void allocate (int capacity)
 Allocate an array of pointers to Data. More...
 
void append (Data &data)
 Append an element to the end of the sequence. More...
 
void clear ()
 Reset to empty state. More...
 
bool isAllocated () const
 Is this DPArray allocated? More...
 
- Public Member Functions inherited from Util::PArray< Data >
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...
 

Additional Inherited Members

- Protected Member Functions inherited from Util::PArray< Data >
 PArray ()
 Constructor (protected to prevent instantiation). More...
 
- Protected Attributes inherited from Util::PArray< Data >
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::DPArray< Data >

A dynamic array that only holds pointers to its elements.

Definition at line 24 of file DPArray.h.

Constructor & Destructor Documentation

◆ DPArray() [1/2]

template<typename Data >
Util::DPArray< Data >::DPArray
inline

Constructor.

Definition at line 101 of file DPArray.h.

◆ DPArray() [2/2]

template<typename Data >
Util::DPArray< Data >::DPArray ( DPArray< Data > const &  other)

Copy constructor, copy pointers.

Allocates new Data* array and copies pointers to Data objects.

Parameters
otherthe DPArray to be copied.

Definition at line 111 of file DPArray.h.

References Util::PArray< Data >::capacity_, Util::DPArray< Data >::isAllocated(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.

◆ ~DPArray()

template<typename Data >
Util::DPArray< Data >::~DPArray
virtual

Destructor.

Deletes array of pointers, if allocated previously. Does not delete the associated Data objects.

Definition at line 177 of file DPArray.h.

Member Function Documentation

◆ operator=()

template<typename Data >
DPArray< Data > & Util::DPArray< Data >::operator= ( DPArray< Data > const &  other)

Assignment, element by element.

Preconditions:

  • Both this and other DPArrays must be allocated.
  • Capacity of this DPArray must be >= size of RHS DPArray.
Parameters
otherthe rhs DPArray

Definition at line 139 of file DPArray.h.

References Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.

◆ allocate()

template<typename Data >
void Util::DPArray< Data >::allocate ( int  capacity)

Allocate an array of pointers to Data.

Throw an Exception if the DPArray has already been allocated - A DPArray can only be allocated once.

Parameters
capacitynumber of elements to allocate.

Definition at line 191 of file DPArray.h.

References UTIL_THROW.

◆ append()

template<typename Data >
void Util::DPArray< Data >::append ( Data &  data)
inline

Append an element to the end of the sequence.

Parameters
dataData object to be appended

Definition at line 208 of file DPArray.h.

References UTIL_THROW.

◆ clear()

template<typename Data >
void Util::DPArray< Data >::clear

Reset to empty state.

Definition at line 224 of file DPArray.h.

◆ isAllocated()

template<typename Data >
bool Util::DPArray< Data >::isAllocated
inline

Is this DPArray allocated?

Definition at line 235 of file DPArray.h.

Referenced by Util::DPArray< Data >::DPArray().


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