Simpatico
v1.10
|
Statically allocated pointer array.
A FPArray is a statically allocated array that actually holds pointers to Data objects, but for which the [] operator returns a reference to the associated object. It is implemented as a wrapper for a statically allocated C array of Data* pointers. A FPArray is not responsible for destroying the associated Data objects.
The interface of an FPArray is identical to that of an FSArray. An FPArray has both a capacity that is set at compile time, which is the physical size of the underlying C array, and a size, which is the number of contiguous elements (indexed from 0 to size-1) that contain valid pointers. The size can only be increased only by the append() method, which adds an element to the end of the array.
When compiled in debug mode, the operator [] checks that the index is less than the size and non-negative.
#include <FPArray.h>
Public Member Functions | |
FPArray () | |
Default constructor. More... | |
FPArray (const FPArray< Data, Capacity > &other) | |
Copy constructor. More... | |
~FPArray () | |
Destructor. More... | |
FPArray< Data, Capacity > & | operator= (const FPArray< Data, Capacity > &other) |
Assignment, element by element. More... | |
void | append (Data &data) |
Append an element to the end of the array. More... | |
void | clear () |
Set logical size to zero and nullify all elements. More... | |
int | capacity () const |
Return physical capacity of array. More... | |
int | size () const |
Return logical size of this array. More... | |
void | begin (PArrayIterator< Data > &iterator) |
Set an iterator to begin this container. More... | |
void | begin (ConstPArrayIterator< Data > &iterator) const |
Set a const iterator to begin this container. More... | |
Data & | operator[] (int i) |
Get an element by reference (mimic C-array subscripting). More... | |
const Data & | operator[] (int i) const |
Get an element by const reference (mimic C-array subscripting). More... | |
Protected Attributes | |
Data * | ptrs_ [Capacity] |
Array of pointers to Data objects. More... | |
int | size_ |
Logical size of array (number of elements used). More... | |
|
inline |
Util::FPArray< Data, Capacity >::FPArray | ( | const FPArray< Data, Capacity > & | other | ) |
Copy constructor.
Copies all pointers.
other | the FPArray to be copied. |
Definition at line 147 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, and Util::FPArray< Data, Capacity >::size_.
Util::FPArray< Data, Capacity >::~FPArray | ( | ) |
FPArray< Data, Capacity > & Util::FPArray< Data, Capacity >::operator= | ( | const FPArray< Data, Capacity > & | other | ) |
Assignment, element by element.
other | the rhs FPArray |
Definition at line 171 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, Util::FPArray< Data, Capacity >::size_, and UTIL_THROW.
|
inline |
Append an element to the end of the array.
data | Data to add to end of array. |
Definition at line 275 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, Util::FPArray< Data, Capacity >::size_, and UTIL_THROW.
|
inline |
Set logical size to zero and nullify all elements.
Definition at line 288 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, and Util::FPArray< Data, Capacity >::size_.
|
inline |
|
inline |
Return logical size of this array.
Definition at line 216 of file FPArray.h.
References Util::FPArray< Data, Capacity >::size_.
|
inline |
Set an iterator to begin this container.
iterator | PArrayIterator, initialized on output. |
Definition at line 224 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, Util::PArrayIterator< Data >::setCurrent(), Util::PArrayIterator< Data >::setEnd(), and Util::FPArray< Data, Capacity >::size_.
|
inline |
Set a const iterator to begin this container.
iterator | ConstPArrayIterator, initialized on output. |
Definition at line 235 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, Util::ConstPArrayIterator< Data >::setCurrent(), Util::ConstPArrayIterator< Data >::setEnd(), and Util::FPArray< Data, Capacity >::size_.
|
inline |
Get an element by reference (mimic C-array subscripting).
i | array index |
Definition at line 248 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, and Util::FPArray< Data, Capacity >::size_.
|
inline |
Get an element by const reference (mimic C-array subscripting).
i | array index |
Definition at line 262 of file FPArray.h.
References Util::FPArray< Data, Capacity >::ptrs_, and Util::FPArray< Data, Capacity >::size_.
|
protected |
Array of pointers to Data objects.
Definition at line 126 of file FPArray.h.
Referenced by Util::FPArray< Data, Capacity >::append(), Util::FPArray< Data, Capacity >::begin(), Util::FPArray< Data, Capacity >::clear(), Util::FPArray< Data, Capacity >::FPArray(), Util::FPArray< Data, Capacity >::operator=(), and Util::FPArray< Data, Capacity >::operator[]().
|
protected |
Logical size of array (number of elements used).
Definition at line 129 of file FPArray.h.
Referenced by Util::FPArray< Data, Capacity >::append(), Util::FPArray< Data, Capacity >::begin(), Util::FPArray< Data, Capacity >::clear(), Util::FPArray< Data, Capacity >::FPArray(), Util::FPArray< Data, Capacity >::operator=(), Util::FPArray< Data, Capacity >::operator[](), and Util::FPArray< Data, Capacity >::size().