Simpatico
v1.10
|
A dynamic array that only holds pointers to its elements.
#include <DPArray.h>
Public Member Functions | |
DPArray () | |
Constructor. More... | |
DPArray (const DPArray< Data > &other) | |
Copy constructor, copy pointers. More... | |
virtual | ~DPArray () |
Destructor. More... | |
DPArray< Data > & | operator= (const DPArray< Data > &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... | |
![]() | |
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 | |
![]() | |
PArray () | |
Constructor (protected to prevent instantiation). More... | |
![]() | |
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... | |
|
inline |
Util::DPArray< Data >::DPArray | ( | const DPArray< Data > & | other | ) |
Copy constructor, copy pointers.
Allocates new Data* array and copies pointers to Data objects.
other | the DPArray to be copied. |
Allocates a new Data* array and copies all pointer values.
other | the DPArray to be copied. |
Definition at line 113 of file DPArray.h.
References Util::PArray< Data >::capacity_, Util::DPArray< Data >::isAllocated(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
|
virtual |
Destructor.
Deletes array of pointers, if allocated previously. Does not delete the associated Data objects.
Definition at line 179 of file DPArray.h.
References Util::PArray< Data >::capacity_, Util::PArray< Data >::ptrs_, and Util::PArray< Data >::size_.
DPArray< Data > & Util::DPArray< Data >::operator= | ( | const DPArray< Data > & | other | ) |
Assignment, element by element.
Preconditions:
other | the rhs DPArray |
Definition at line 141 of file DPArray.h.
References Util::PArray< Data >::capacity_, Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
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 193 of file DPArray.h.
References Util::PArray< Data >::capacity(), Util::PArray< Data >::capacity_, Util::PArray< Data >::ptrs_, and UTIL_THROW.
|
inline |
Append an element to the end of the sequence.
data | Data object to be appended |
Definition at line 210 of file DPArray.h.
References Util::PArray< Data >::capacity_, Util::DPArray< Data >::isAllocated(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
void Util::DPArray< Data >::clear | ( | ) |
Reset to empty state.
Definition at line 226 of file DPArray.h.
References Util::DPArray< Data >::isAllocated(), and Util::PArray< Data >::size_.
|
inline |
Is this DPArray allocated?
Definition at line 237 of file DPArray.h.
References Util::PArray< Data >::ptrs_.
Referenced by Util::DPArray< Data >::append(), Util::DPArray< Data >::clear(), and Util::DPArray< Data >::DPArray().