|
PSCF v1.5.0
|
Read-only array container class template. More...
#include <ConstArray.h>
Public Member Functions | |
| Data const & | operator[] (int i) const |
| Get an element by const reference. | |
| void | begin (ConstArrayIterator< Data > &iterator) const |
| Set a const iterator to begin this ConstArray. | |
| Data const * | cArray () const |
| Return a pointer to the underlying C array (pointer to const data). | |
| bool | isAllocated () const |
| Does this array have associated data? | |
| int | size () const |
| Return logical size of this array. | |
| int | capacity () const |
| Return allocated size of this array. | |
Protected Member Functions | |
| ConstArray () | |
| Constructor (protected to prevent direct instantiation). | |
| ~ConstArray () | |
| Destructor (protected to prevent direct destruction). | |
Protected Attributes | |
| Data * | data_ |
| Pointer to an array of Data elements. | |
| int | capacity_ |
| Allocated size of the data_ array. | |
Read-only array container class template.
A ConstArray is a sequence container that supports random read-only access to elements via a operator [] that returns a const reference, or via a ConstArrayIterator. Similar to an Array, without any of the functions that provide write access to element values.
The ConstArray class template is designed to be used as only as a base class, and does not provide functions for memory management. The ConstArray template has a protected constructor and destructor to prevent direct direct construction or destruction, but to allow construction and destruction as a subojbect of a derived class.
When compiled in debug mode (i.e., when NDEBUG is not defined) the subscript operator [] checks the validity of the element index.
Definition at line 37 of file ConstArray.h.
|
inlineprotected |
Constructor (protected to prevent direct instantiation).
Subclasses have responsibility for memory management.
Definition at line 125 of file ConstArray.h.
|
protected |
Destructor (protected to prevent direct destruction).
Definition at line 136 of file ConstArray.h.
|
inline |
Get an element by const reference.
Mimics C-array subscripting.
| i | array index |
Definition at line 143 of file ConstArray.h.
|
inline |
Set a const iterator to begin this ConstArray.
On return, iterator points to the first element of the array, and the iterator end pointer points one past the last element.
| iterator | ConstArrayIterator, initialized on output |
Definition at line 155 of file ConstArray.h.
References capacity_, data_, Util::ConstArrayIterator< Data >::setCurrent(), and Util::ConstArrayIterator< Data >::setEnd().
|
inline |
Return a pointer to the underlying C array (pointer to const data).
Definition at line 167 of file ConstArray.h.
References data_.
|
inline |
Does this array have associated data?
Return false if the pointer to data is null, true otherwise.
Definition at line 174 of file ConstArray.h.
References data_.
Referenced by Pscf::HostRecvArray< Data, CUT >::allocate(), Pscf::HostRecvArray< Data, CUT >::copySlice(), Pscf::HostRecvArray< Data, CUT >::deallocate(), Pscf::HostRecvArray< Data, CUT >::operator=(), Pscf::HostRecvArray< Data, CUT >::operator=(), Pscf::HostRecvArray< Data, CUT >::serialize(), and Pscf::HostRecvArray< Data, CUT >::~HostRecvArray().
|
inline |
Return logical size of this array.
Currently, capacity() == size(), always.
Definition at line 181 of file ConstArray.h.
References capacity_.
|
inline |
Return allocated size of this array.
Definition at line 188 of file ConstArray.h.
References capacity_.
Referenced by Pscf::HostRecvArray< Data, CUT >::allocate(), Pscf::HostRecvArray< Data, CUT >::copySlice(), Pscf::HostRecvArray< Data, CUT >::HostRecvArray(), Pscf::HostRecvArray< Data, CUT >::HostRecvArray(), Pscf::HostRecvArray< Data, CUT >::operator=(), and Pscf::HostRecvArray< Data, CUT >::serialize().
|
protected |
Pointer to an array of Data elements.
Definition at line 114 of file ConstArray.h.
Referenced by Pscf::HostRecvArray< Data, CUT >::allocate(), begin(), cArray(), ConstArray(), Pscf::HostRecvArray< Data, CUT >::copySlice(), Pscf::HostRecvArray< Data, CUT >::deallocate(), Pscf::HostRecvArray< Data, CPT >::dissociate(), isAllocated(), Pscf::HostRecvArray< Data, CUT >::operator=(), Pscf::HostRecvArray< Data, CUT >::operator=(), operator[](), Pscf::HostRecvArray< Data, CUT >::serialize(), and Pscf::HostRecvArray< Data, CUT >::~HostRecvArray().
|
protected |
Allocated size of the data_ array.
Definition at line 117 of file ConstArray.h.
Referenced by Pscf::HostRecvArray< Data, CUT >::allocate(), begin(), capacity(), ConstArray(), Pscf::HostRecvArray< Data, CUT >::deallocate(), Pscf::HostRecvArray< Data, CPT >::dissociate(), Pscf::HostRecvArray< Data, CUT >::operator=(), operator[](), Pscf::HostRecvArray< Data, CUT >::serialize(), size(), and Pscf::HostRecvArray< Data, CUT >::~HostRecvArray().