|
PSCF v1.3.3
|
An Array that acts as a reference to another Array or C array. More...
#include <RArray.h>
Public Member Functions | |
| RArray () | |
| Constructor. | |
| RArray (RArray< Data > const &other) | |
| Copy constructor. | |
| void | associate (Array< Data > &array) |
| Associate this RArray with an existing Array object. | |
| void | associate (Data *array, int capacity) |
| Associate this RArray with an existing C array. | |
| Public Member Functions inherited from Util::Array< Data > | |
| virtual | ~Array () |
| Destructor. | |
| int | capacity () const |
| Return allocated size. | |
| void | begin (ArrayIterator< Data > &iterator) |
| Set an iterator to begin this Array. | |
| void | begin (ConstArrayIterator< Data > &iterator) const |
| Set a const iterator to begin this Array. | |
| Data & | operator[] (int i) |
| Get an element by non-const reference. | |
| Data const & | operator[] (int i) const |
| Get an element by const reference. | |
| Data * | cArray () |
| Return a pointer to the underlying C array. | |
| Data const * | cArray () const |
| Return pointer to const to the underlying C array. | |
Additional Inherited Members | |
| Protected Member Functions inherited from Util::Array< Data > | |
| Array () | |
| Default constructor. | |
| Protected Attributes inherited from Util::Array< Data > | |
| Data * | data_ |
| Pointer to an array of Data elements. | |
| int | capacity_ |
| Allocated size of the data_ array. | |
An Array that acts as a reference to another Array or C array.
An RArray is associated with a "target" DArray or C array by the associate() method. The RArray and its target array then wrap the same underlying C array, and so access the same data. The associate() method simply copies the address and capacity of a C array. An RArray can be associated only once, after which it can be safely used as an alias for its target.
An RArray can only be associated with a DArray after the target DArray has been allocated. Because a DArray can be allocated only once, this association cannot be corrupted by re-allocation or re-sizing of the target DArray.
An RArray can be created from another RArray only after the target RArray has already been associated with some other Array.
An RArray differs from a C++ reference to an Array because a C++ reference must be initialized when it is instantiated, whereas an RArray is associated after it is instantiated. Because association is implemented by copying the address and capacity of a shared C array, access through an RArray should be exactly as efficient as access through a DArray.
|
inline |
Constructor.
Definition at line 57 of file RArray.h.
References Util::Array< Data >::Array().
Referenced by RArray().
|
inline |
Copy constructor.
Shallow copy of another RArray
| other | another RArray<Data> for which this is an alias. |
Definition at line 68 of file RArray.h.
References Util::Array< Data >::Array(), Util::Array< Data >::capacity_, Util::Array< Data >::data_, and RArray().
|
inline |
Associate this RArray with an existing Array object.
The target (i.e., the parameter array) must be allocated when this method is invoked, as discussed in the RArray class documentation.
| array | the target Array |
Definition at line 83 of file RArray.h.
References Util::Array< Data >::Array(), Util::Array< Data >::capacity(), Util::Array< Data >::capacity_, Util::Array< Data >::data_, and UTIL_THROW.
|
inline |
Associate this RArray with an existing C array.
| array | the target C array |
| capacity | the number of elements in the target array |
Definition at line 101 of file RArray.h.
References Util::Array< Data >::capacity(), Util::Array< Data >::capacity_, Util::Array< Data >::data_, and UTIL_THROW.