fesa-core  4.3.1
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl > Class Template Reference

#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.
 

Detailed Description

template<typename T, bool runtimeCheck = true, typename ArrayImpl = Array<T, runtimeCheck>>
class fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >

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

Template Parameters
TType of the elements
runtimeCheckwhether to check index boundaries at runtime
ArrayImplA type that is an implementation of an array

Constructor & Destructor Documentation

template<typename T, bool runtimeCheck, typename ArrayImpl >
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.

Parameters
datapointer to elements to use. There must be at least nElements elements pointed.
nElementsnumber of elements in this array
template<typename T, bool runtimeCheck, typename ArrayImpl >
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.

Parameters
firstpointer to the first element of the array
lastpointer to the element after the last element to be included in the array
template<typename T, bool runtimeCheck, typename ArrayImpl >
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.

template<typename T, bool runtimeCheck, typename ArrayImpl >
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::ImmutableArray ( )

Constructor. Sets the data pointer to NULL and the number of elements to 0.

Member Function Documentation

template<typename T , bool runtimeCheck, typename ArrayImpl >
ArrayImpl fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::getMutable ( ) const

Returns an ArrayImpl object that contains a copy of the elements of this ImmutableArray

template<typename T , bool runtimeCheck, typename ArrayImpl >
fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::operator const T * ( ) const

Converts this object to a T* by returning the pointer to the data.

template<typename T , bool runtimeCheck, typename ArrayImpl >
template<typename S >
const T & fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::operator[] ( index) const

Returns the element at the given index (read-only).

template<typename T , bool runtimeCheck, typename ArrayImpl >
std::size_t fesa::ImmutableArray< T, runtimeCheck, ArrayImpl >::size ( ) const

Returns the number of elements of this array.


The documentation for this class was generated from the following file: