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

#include <Array2D.h>

Inheritance diagram for fesa::Array2D< T, runtimeCheck >:
fesa::ImmutableArray2D< T, runtimeCheck >

Public Member Functions

 Array2D (const T *data, std::size_t nRows, std::size_t nCols)
 
 Array2D (std::size_t nRows, std::size_t nCols)
 
template<typename S >
Array2DRow< T, runtimeCheck > operator[] (S index)
 
T & get (std::size_t row, std::size_t column)
 
- Public Member Functions inherited from fesa::ImmutableArray2D< T, runtimeCheck >
 ImmutableArray2D (const boost::shared_array< T > &data, std::size_t nRows, std::size_t nCols)
 
 ImmutableArray2D (const T *data, std::size_t nRows, std::size_t nCols)
 
 ImmutableArray2D (const ImmutableArray2D< T, runtimeCheck > &other)
 
ImmutableArray2D< T > & operator= (const ImmutableArray2D< T > &other)
 
Array2D< T, runtimeCheck > getMutable () const
 
std::size_t getNumberOfRows () const
 
std::size_t getNumberOfColumns () const
 
std::size_t getNumberOfElements () const
 
bool hasOwnData () const
 
template<typename S >
const Array2DRow< T, runtimeCheck > operator[] (S index) const
 
const T & get (std::size_t row, std::size_t column) const
 
 operator const T * () const
 
 operator const void * () const
 

Additional Inherited Members

- Protected Member Functions inherited from fesa::ImmutableArray2D< T, runtimeCheck >
 ImmutableArray2D (std::size_t nRows, std::size_t nCols)
 
void doRuntimeCheck (std::size_t row) const
 
void doRuntimeCheck (std::size_t row, std::size_t column) const
 
- Protected Attributes inherited from fesa::ImmutableArray2D< T, runtimeCheck >
std::size_t nRows_
 
std::size_t nCols_
 
boost::container::vector< T > ownData_
 
const boost::shared_array< T > sharedData_
 
const T * data_
 

Detailed Description

template<typename T, bool runtimeCheck = true>
class fesa::Array2D< T, runtimeCheck >

A wrapper class for 2-dimensional arrays. An Array2D has always its own copy of the data. Consequently, the data passed to its constructor can be safely destroyed. An Array2D also provides a subscript operator which allows modification of the data.

Template Parameters
TType of the elements
runtimeCheckwhether to check index boundaries at runtime

Constructor & Destructor Documentation

template<typename T , bool runtimeCheck>
fesa::Array2D< T, runtimeCheck >::Array2D ( const T *  data,
std::size_t  nRows,
std::size_t  nCols 
)

Constructor. Performs a copy of elements pointed to by data.

Parameters
datapointer to elements to copy. There must be at least nRows * nCols elements pointed.
nRowsnumber of rows of this array
nColsnumber of columns of this array
template<typename T , bool runtimeCheck>
fesa::Array2D< T, runtimeCheck >::Array2D ( std::size_t  nRows,
std::size_t  nCols 
)

Constructor. Initializes nRows * nCols elements.

Parameters
nRows
nCols

Member Function Documentation

template<typename T , bool runtimeCheck>
T & fesa::Array2D< T, runtimeCheck >::get ( std::size_t  row,
std::size_t  column 
)

Returns a reference to the element at the given row, column. This method has the best performance. It shoud be favored over operator[], especially when iterating over the whole array.

template<typename T , bool runtimeCheck>
template<typename S >
Array2DRow< T, runtimeCheck > fesa::Array2D< T, runtimeCheck >::operator[] ( index)

Returns a reference to the row at the given index (read-write).

Parameters
indexthe row index

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