PSCF v1.1
|
An automatically growable PArray. More...
#include <GPArray.h>
Public Member Functions | |
GPArray () | |
Constructor. More... | |
GPArray (GPArray< Data > const &other) | |
Copy constructor, copy pointers. More... | |
GPArray< Data > & | operator= (GPArray< Data > const &other) |
Assignment, element by element. More... | |
virtual | ~GPArray () |
Destructor. More... | |
void | append (Data &data) |
Append an element to the end of the sequence. More... | |
void | reserve (int capacity) |
Reserve memory for specified number of elements. More... | |
void | deallocate () |
Deallocate (delete) underlying array of pointers. More... | |
void | clear () |
Reset to empty state. More... | |
bool | isAllocated () const |
Is this GPArray 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... | |
An automatically growable PArray.
An GPArray is a PArray that grows as needed as objects are appended. Like any PArray, it holds pointers to objects, rather than objects. The associated objects are not destroyed when a PArray is deallocated or destroyed.
|
inline |
Util::GPArray< Data >::GPArray | ( | GPArray< Data > const & | other | ) |
Copy constructor, copy pointers.
Allocates new Data* array and copies pointers to Data objects.
other | the GPArray to be copied. |
Definition at line 123 of file GPArray.h.
References Util::PArray< Data >::capacity_, 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 174 of file GPArray.h.
References Util::Memory::deallocate().
GPArray< Data > & Util::GPArray< Data >::operator= | ( | GPArray< Data > const & | other | ) |
void Util::GPArray< Data >::append | ( | Data & | data | ) |
void Util::GPArray< Data >::reserve | ( | int | capacity | ) |
Reserve memory for specified number of elements.
Resizes and copies array if requested capacity is less than the current capacity. Does nothing if requested capacity is greater than current capacity.
capacity | number of elements for which to reserve space. |
Definition at line 187 of file GPArray.h.
References UTIL_THROW.
void Util::GPArray< Data >::deallocate |
|
inline |
|
inline |