|
PSCF v1.3.3
|
An automatically growable PArray. More...
#include <GPArray.h>
Public Member Functions | |
| GPArray () | |
| Constructor. | |
| GPArray (GPArray< Data > const &other) | |
| Copy constructor, copy pointers. | |
| GPArray< Data > & | operator= (GPArray< Data > const &other) |
| Assignment, element by element. | |
| virtual | ~GPArray () |
| Destructor. | |
| void | append (Data &data) |
| Append an element to the end of the sequence. | |
| void | reserve (int capacity) |
| Reserve memory for specified number of elements. | |
| void | deallocate () |
| Deallocate (delete) underlying array of pointers. | |
| void | clear () |
| Reset to empty state. | |
| bool | isAllocated () const |
| Is this GPArray 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). | |
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 |
Constructor.
Definition at line 113 of file GPArray.h.
References Util::PArray< Data >::PArray().
Referenced by GPArray(), and operator=().
| 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::Memory::allocate(), Util::PArray< Data >::capacity_, GPArray(), 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 174 of file GPArray.h.
References Util::PArray< Data >::capacity_, Util::Memory::deallocate(), isAllocated(), Util::PArray< Data >::ptrs_, and Util::PArray< Data >::size_.
| GPArray< Data > & Util::GPArray< Data >::operator= | ( | GPArray< Data > const & | other | ) |
| void Util::GPArray< Data >::append | ( | Data & | data | ) |
Append an element to the end of the sequence.
Resizes array if space is inadequate.
| data | Data object to be appended |
Definition at line 233 of file GPArray.h.
References Util::Memory::allocate(), Util::PArray< Data >::capacity_, Util::Memory::deallocate(), isAllocated(), Util::PArray< Data >::ptrs_, and Util::PArray< Data >::size_.
Referenced by operator=().
| 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::Memory::allocate(), Util::PArray< Data >::capacity(), Util::PArray< Data >::capacity_, Util::Memory::deallocate(), Util::PArray< Data >::ptrs_, Util::PArray< Data >::size_, and UTIL_THROW.
| void Util::GPArray< Data >::deallocate | ( | ) |
Deallocate (delete) underlying array of pointers.
Definition at line 219 of file GPArray.h.
References Util::PArray< Data >::capacity_, Util::Memory::deallocate(), isAllocated(), Util::PArray< Data >::ptrs_, and Util::PArray< Data >::size_.
|
inline |
Reset to empty state.
Definition at line 266 of file GPArray.h.
References Util::PArray< Data >::size_.
Referenced by operator=().
|
inline |
Is this GPArray allocated?
Definition at line 273 of file GPArray.h.
References Util::PArray< Data >::ptrs_.
Referenced by append(), deallocate(), and ~GPArray().