|
PSCF v1.4.0
|
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 > | |
| 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 () | |
| Constructor (protected to provent direct instantiation). | |
| ~Array () | |
| Destructor (protected to prevent direct destruction). | |
| 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 used as an alias for its target.
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 |
|
inline |
Copy constructor.
Shallow copy of another RArray
| other | another RArray<Data> for which this is an alias. |
Definition at line 60 of file RArray.h.
References Util::Array< Data >::capacity(), Util::Array< Data >::capacity_, Util::Array< Data >::data_, RArray(), and UTIL_CHECK.
|
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 77 of file RArray.h.
References 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 95 of file RArray.h.
References Util::Array< Data >::capacity(), Util::Array< Data >::capacity_, Util::Array< Data >::data_, and UTIL_THROW.