fesa-core
4.3.1
|
#include <ImmutableArray.h>
Public Member Functions | |
ImmutableArray (const T *data, std::size_t nElements) | |
ImmutableArray (const T *first, const T *last) | |
ImmutableArray (const std::vector< T > &values) | |
ImmutableArray () | |
operator const T * () const | |
template<typename S > | |
const T & | operator[] (S index) const |
ArrayImpl | getMutable () const |
std::size_t | size () const |
Protected Attributes | |
std::size_t | nElements_ |
The number of elements of this ImmutableArray. | |
const T * | data_ |
The pointer to the elements of this ImmutableArray. | |
A wrapper class for arrays. An ImmutableArray doesn't copy any data and works on the raw data provided to its constructor. As the name suggests, an ImmutableArray doesn't allow modification of its data. In order to create a modifiable copy of the data, 'getMutable()' can be used. It returns an ArrayImpl object
T | Type of the elements |
runtimeCheck | whether to check index boundaries at runtime |
ArrayImpl | A type that is an implementation of an array |
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::ImmutableArray | ( | const T * | data, |
std::size_t | nElements | ||
) |
Constructor. No copy of the data is performed; elements pointed to by data must not be destroyed before this ImmutableArray is.
data | pointer to elements to use. There must be at least nElements elements pointed. |
nElements | number of elements in this array |
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::ImmutableArray | ( | const T * | first, |
const T * | last | ||
) |
Constructor. No copy of the data is performed; elements pointed to must not be destroyed before this ImmutableArray is. This constructs an ImmutableArray which includes the range [first,last) meaning last is excluded.
first | pointer to the first element of the array |
last | pointer to the element after the last element to be included in the array |
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::ImmutableArray | ( | const std::vector< T > & | values | ) |
Constructor. No copy of the data is performed; values must remain accessible until this is destroyed.
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::ImmutableArray | ( | ) |
Constructor. Sets the data pointer to NULL and the number of elements to 0.
ArrayImpl fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::getMutable | ( | ) | const |
Returns an ArrayImpl object that contains a copy of the elements of this ImmutableArray
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::operator const T * | ( | ) | const |
Converts this object to a T* by returning the pointer to the data.
const T & fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::operator[] | ( | S | index | ) | const |
Returns the element at the given index (read-only).
std::size_t fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::size | ( | ) | const |
Returns the number of elements of this array.