Simple Application Framework
1
|
Multi-dimensional array of values. More...
#include <Array.h>
Public Types | |
typedef const T * | ConstIterator |
Random-access non-mutable Array iterator. | |
typedef T * | Iterator |
Random-access mutable Array iterator. | |
Public Member Functions | |
Array () | |
Default constructor. | |
Array (const Math::Algebra::Vector< N, Size > &dim) | |
Constructor. | |
Array (const Math::Algebra::Vector< N, Size > &dim, const T &val) | |
Constructor. | |
Array (Size sz) | |
Constructor applicable to one-dimensional arrays. | |
Array (Size sz, const T &val) | |
Constructor applicable to one-dimensional arrays. | |
Array (const MyType &v) | |
Copy constructor. | |
~Array () | |
Destructor. | |
Iterator | Back () |
Iterator to the last element. | |
ConstIterator | Back () const |
Iterator to the last element. | |
Iterator | Begin () |
Iterator to the first element. | |
ConstIterator | Begin () const |
Iterator to the first element. | |
void | Coord (Size idx, Math::Algebra::Vector< N, Size > &coord) const |
Calculate the coordinates of an element with a given index. | |
void | Coords (const Collection::Array< 1, Size > &iv, Collection::Array< 1, Math::Algebra::Vector< N, Size > > &cv) const |
Calculate the coordinates of elements with given indexes. | |
const Math::Algebra::Vector< N, Size > & | Dimensions () const |
Get array dimensions. | |
Size | Elements () const |
Get total number of elements in the array. | |
Iterator | End () |
Iterator one after the last element. | |
ConstIterator | End () const |
Iterator one after the last element. | |
MyType & | Free () |
Free memory occupied by the array. | |
Iterator | Front () |
Iterator to the first element. | |
ConstIterator | Front () const |
Iterator to the first element. | |
template<class U > | |
U | Index (const Math::Algebra::Vector< N, U > &ofs) const |
Calculate index into the array corresponding to given vector offset. | |
template<class U > | |
void | Indexes (const Collection::Array< 1, Math::Algebra::Vector< N, U > > &ofs, Collection::Array< 1, U > &idx) const |
Calculate indexes into the array corresponding to given vector offsets. | |
bool | IsEmpty () const |
Check if the array is empty. | |
bool | operator!= (const MyType &a) const |
Comparison operator. | |
MyType & | operator= (const MyType &a) |
Assignment operator. | |
bool | operator== (const MyType &a) const |
Comparison operator. | |
T & | operator[] (Size i) |
Subscript operator. | |
const T & | operator[] (Size i) const |
Subscript operator. | |
MyType & | Resize (const Math::Algebra::Vector< N, Size > &dim) |
Resize the array. | |
MyType & | Resize (const Math::Algebra::Vector< N, Size > &dim, const T &val) |
Resize the array. | |
MyType & | Resize (Size sz, const T &val) |
Resize applicable to one-dimensional arrays. | |
MyType & | Resize (Size sz) |
Resize applicable to one-dimensional arrays. | |
const Math::Algebra::Vector< N, Size > & | Stride () const |
Get array element stride. | |
MyType & | Swap (MyType &a) |
Swap the content of two arrays. | |
Static Public Member Functions | |
template<class U > | |
static U | Index (const Math::Algebra::Vector< N, Size > &dim, const Math::Algebra::Vector< N, U > &ofs) |
Calculate index into the array corresponding to given vector offset. | |
template<class U > | |
static void | Indexes (const Math::Algebra::Vector< N, Size > &dim, const Collection::Array< 1, Math::Algebra::Vector< N, U > > &ofs, Collection::Array< 1, U > &idx) |
Calculate indexes into the array corresponding to given vector offsets. | |
Protected Types | |
typedef Array< N, T > | MyType |
Protected Member Functions | |
void | CheckOverflow (const Math::Algebra::Vector< N, Size > &dim) |
Check if it is possible to store data with given dimensions in the memory. | |
void | UpdateCache () |
Recompute cached values. |
Multi-dimensional array of values.
This class represents a multi-dimensional array of data. All elements are stored in one continuous memory region without any memory overhead. The array can be dynamically resized, however, its intended use is for data whose size is set once and then many operations are performed on them, e.g., images. It is not optimized for frequent size changes. During resize the old content is lost.
Alternatives:
Iterator category: Random-access.
N | Number of dimensions. |
T | Data type. |
typedef const T* Saf::Collection::Array< N, T >::ConstIterator |
Random-access non-mutable Array iterator.
typedef T* Saf::Collection::Array< N, T >::Iterator |
Random-access mutable Array iterator.
typedef Array<N,T> Saf::Collection::Array< N, T >::MyType [protected] |
Saf::Collection::Array< N, T >::Array | ( | ) | [inline] |
Default constructor.
Saf::Collection::Array< N, T >::Array | ( | const Math::Algebra::Vector< N, Size > & | dim | ) | [inline, explicit] |
Constructor.
Constructs and resizes the array. Values are initialized with their default constructor.
[in] | dim | Requested dimensions of the array. |
Saf::Collection::Array< N, T >::Array | ( | const Math::Algebra::Vector< N, Size > & | dim, |
const T & | val | ||
) | [inline] |
Constructor.
Constructs and resizes the array. Element values are set to val
.
[in] | dim | Requested dimensions of the array. |
[in] | val | Value used to initialize the elements. |
Saf::Collection::Array< N, T >::Array | ( | Size | sz | ) | [inline, explicit] |
Constructor applicable to one-dimensional arrays.
Constructs and resizes the array. Values are initialized with their default constructor.
[in] | sz | Requested size of the array. |
Saf::Collection::Array< N, T >::Array | ( | Size | sz, |
const T & | val | ||
) | [inline] |
Constructor applicable to one-dimensional arrays.
Constructs and resizes the array. Element values are set to val
.
[in] | sz | Requested size of the array. |
[in] | val | Value used to initialize the elements. |
Saf::Collection::Array< N, T >::Array | ( | const MyType & | v | ) | [inline] |
Copy constructor.
Saf::Collection::Array< N, T >::~Array | ( | ) | [inline] |
Destructor.
Iterator Saf::Collection::Array< N, T >::Back | ( | ) | [inline] |
Iterator to the last element.
ConstIterator Saf::Collection::Array< N, T >::Back | ( | ) | const [inline] |
Iterator to the last element.
Iterator Saf::Collection::Array< N, T >::Begin | ( | ) | [inline] |
Iterator to the first element.
ConstIterator Saf::Collection::Array< N, T >::Begin | ( | ) | const [inline] |
Iterator to the first element.
void Saf::Collection::Array< N, T >::CheckOverflow | ( | const Math::Algebra::Vector< N, Size > & | dim | ) | [inline, protected] |
Check if it is possible to store data with given dimensions in the memory.
void Saf::Collection::Array< N, T >::Coord | ( | Size | idx, |
Math::Algebra::Vector< N, Size > & | coord | ||
) | const [inline] |
Calculate the coordinates of an element with a given index.
void Saf::Collection::Array< N, T >::Coords | ( | const Collection::Array< 1, Size > & | iv, |
Collection::Array< 1, Math::Algebra::Vector< N, Size > > & | cv | ||
) | const [inline] |
const Math::Algebra::Vector<N,Size>& Saf::Collection::Array< N, T >::Dimensions | ( | ) | const [inline] |
Get array dimensions.
Size Saf::Collection::Array< N, T >::Elements | ( | ) | const [inline] |
Get total number of elements in the array.
Properties:
Iterator Saf::Collection::Array< N, T >::End | ( | ) | [inline] |
Iterator one after the last element.
ConstIterator Saf::Collection::Array< N, T >::End | ( | ) | const [inline] |
Iterator one after the last element.
MyType& Saf::Collection::Array< N, T >::Free | ( | ) | [inline] |
Free memory occupied by the array.
Iterator Saf::Collection::Array< N, T >::Front | ( | ) | [inline] |
Iterator to the first element.
ConstIterator Saf::Collection::Array< N, T >::Front | ( | ) | const [inline] |
Iterator to the first element.
U Saf::Collection::Array< N, T >::Index | ( | const Math::Algebra::Vector< N, U > & | ofs | ) | const [inline] |
Calculate index into the array corresponding to given vector offset.
static U Saf::Collection::Array< N, T >::Index | ( | const Math::Algebra::Vector< N, Size > & | dim, |
const Math::Algebra::Vector< N, U > & | ofs | ||
) | [inline, static] |
Calculate index into the array corresponding to given vector offset.
Static version of the method.
[in] | dim | Dimensions of the array. |
[in] | ofs | Offset for which the index should be computed. |
void Saf::Collection::Array< N, T >::Indexes | ( | const Collection::Array< 1, Math::Algebra::Vector< N, U > > & | ofs, |
Collection::Array< 1, U > & | idx | ||
) | const [inline] |
static void Saf::Collection::Array< N, T >::Indexes | ( | const Math::Algebra::Vector< N, Size > & | dim, |
const Collection::Array< 1, Math::Algebra::Vector< N, U > > & | ofs, | ||
Collection::Array< 1, U > & | idx | ||
) | [inline, static] |
bool Saf::Collection::Array< N, T >::IsEmpty | ( | ) | const [inline] |
Check if the array is empty.
bool Saf::Collection::Array< N, T >::operator!= | ( | const MyType & | a | ) | const [inline] |
Comparison operator.
MyType& Saf::Collection::Array< N, T >::operator= | ( | const MyType & | a | ) | [inline] |
Assignment operator.
bool Saf::Collection::Array< N, T >::operator== | ( | const MyType & | a | ) | const [inline] |
Comparison operator.
T& Saf::Collection::Array< N, T >::operator[] | ( | Size | i | ) | [inline] |
Subscript operator.
const T& Saf::Collection::Array< N, T >::operator[] | ( | Size | i | ) | const [inline] |
Subscript operator.
MyType& Saf::Collection::Array< N, T >::Resize | ( | const Math::Algebra::Vector< N, Size > & | dim | ) | [inline] |
Resize the array.
If the new number of elements is different then the old content is lost during this operation and the values are initialized using their default constructor. Otherwise, only the dimensions and stride are updated.
[in] | dim | New array dimensions. |
MyType& Saf::Collection::Array< N, T >::Resize | ( | const Math::Algebra::Vector< N, Size > & | dim, |
const T & | val | ||
) | [inline] |
Resize the array.
The old content of the array is lost and values of new elements are set to val
.
[in] | dim | New array dimensions. |
[in] | val | Value of the new elements. |
MyType& Saf::Collection::Array< N, T >::Resize | ( | Size | sz, |
const T & | val | ||
) | [inline] |
Resize applicable to one-dimensional arrays.
MyType& Saf::Collection::Array< N, T >::Resize | ( | Size | sz | ) | [inline] |
Resize applicable to one-dimensional arrays.
const Math::Algebra::Vector<N,Size>& Saf::Collection::Array< N, T >::Stride | ( | ) | const [inline] |
Get array element stride.
MyType& Saf::Collection::Array< N, T >::Swap | ( | MyType & | a | ) | [inline] |
Swap the content of two arrays.
Properties:
void Saf::Collection::Array< N, T >::UpdateCache | ( | ) | [inline, protected] |
Recompute cached values.