|
Simpatico
v1.10
|
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.
#include <RArray.h>
Public Member Functions | |
| RArray () | |
| Constructor. More... | |
| RArray (const RArray< Data > &other) | |
| Copy constructor. More... | |
| void | associate (Array< Data > &array) |
| Associate this RArray with an existing Array object. More... | |
| void | associate (Data *array, int capacity) |
| Associate this RArray with an existing C array. More... | |
Public Member Functions inherited from Util::Array< Data > | |
| virtual | ~Array () |
| Destructor. More... | |
| int | capacity () const |
| Return allocated size. More... | |
| void | begin (ArrayIterator< Data > &iterator) |
| Set an iterator to begin this Array. More... | |
| void | begin (ConstArrayIterator< Data > &iterator) const |
| Set a const iterator to begin this Array. More... | |
| Data & | operator[] (int i) |
| Get an element by non-const reference. More... | |
| const Data & | operator[] (int i) const |
| Get an element by const reference. More... | |
| Data * | cArray () |
| Return pointer to underlying C array. More... | |
| const Data * | cArray () const |
| Return pointer to const to underlying C array. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Util::Array< Data > | |
| Array () | |
| Default constructor. More... | |
Protected Attributes inherited from Util::Array< Data > | |
| Data * | data_ |
| Pointer to an array of Data elements. More... | |
| int | capacity_ |
| Allocated size of the data_ array. More... | |
|
inline |
|
inline |
|
inline |
|
inline |
1.8.11