PSCF v1.3
|
A dynamic array that only holds pointers to its elements. More...
#include <DPArray.h>
Public Member Functions | |
DPArray () | |
Constructor. | |
DPArray (DPArray< Data > const &other) | |
Copy constructor, copy pointers. | |
virtual | ~DPArray () |
Destructor. | |
DPArray< Data > & | operator= (DPArray< Data > const &other) |
Assignment, element by element. | |
void | allocate (int capacity) |
Allocate an array of pointers to Data. | |
void | append (Data &data) |
Append an element to the end of the sequence. | |
void | clear () |
Reset to empty state. | |
bool | isAllocated () const |
Is this DPArray allocated? | |
Public Member Functions inherited from Util::PArray< Data > | |
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. |
Additional Inherited Members | |
Protected Member Functions inherited from Util::PArray< Data > | |
PArray () | |
Constructor (protected to prevent instantiation). | |
Protected Attributes inherited from Util::PArray< Data > | |
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). |
A dynamic array that only holds pointers to its elements.
|
inline |
Constructor.
Definition at line 101 of file DPArray.h.
References Util::PArray< Data >::PArray().
Referenced by DPArray(), and operator=().
Util::DPArray< Data >::DPArray | ( | DPArray< Data > const & | other | ) |
Copy constructor, copy pointers.
Allocates new Data* array and copies pointers to Data objects.
other | the DPArray to be copied. |
Definition at line 111 of file DPArray.h.
References Util::PArray< Data >::capacity_, DPArray(), isAllocated(), Util::PArray< Data >::PArray(), Util::PArray< Data >::ptrs_, and Util::PArray< Data >::size_.
|
virtual |
Destructor.
Deletes array of pointers, if allocated previously. Does not delete the associated Data objects.
Definition at line 177 of file DPArray.h.
References Util::PArray< Data >::capacity_, Util::Memory::deallocate(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and ~DPArray().
Referenced by ~DPArray().
DPArray< Data > & Util::DPArray< Data >::operator= | ( | DPArray< Data > const & | other | ) |
Assignment, element by element.
Preconditions:
other | the rhs DPArray |
Definition at line 139 of file DPArray.h.
References Util::PArray< Data >::capacity_, DPArray(), operator=(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
Referenced by operator=().
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.
capacity | number of elements to allocate. |
Definition at line 191 of file DPArray.h.
References allocate(), Util::Memory::allocate(), Util::PArray< Data >::capacity(), Util::PArray< Data >::capacity_, Util::PArray< Data >::ptrs_, and UTIL_THROW.
Referenced by allocate().
|
inline |
Append an element to the end of the sequence.
data | Data object to be appended |
Definition at line 208 of file DPArray.h.
References append(), Util::PArray< Data >::capacity_, isAllocated(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
Referenced by append().
void Util::DPArray< Data >::clear | ( | ) |
Reset to empty state.
Definition at line 224 of file DPArray.h.
References clear(), isAllocated(), and Util::PArray< Data >::size_.
Referenced by clear().
|
inline |
Is this DPArray allocated?
Definition at line 235 of file DPArray.h.
References isAllocated(), and Util::PArray< Data >::ptrs_.
Referenced by append(), clear(), DPArray(), and isAllocated().