#include <N1DArray.h>
Collaboration diagram for N1DArray< stored_type >:
Public Member Functions | |
Iterator | begin () |
Iterator | end () |
int | get1D (vector< unsigned int > index) |
N1DArray (vector< unsigned int > sizes) | |
N1DArray (unsigned int x, unsigned int y, unsigned int z, unsigned int w) | |
~N1DArray () | |
stored_type | get (vector< unsigned int > index) |
void | set (vector< unsigned int > index, stored_type obj) |
void | resize (vector< unsigned int > sizes) |
Protected Member Functions | |
bool | checkIndex (vector< unsigned int > index) |
Protected Attributes | |
unsigned int | size |
unsigned int | _dimension |
vector< unsigned int > | _sizes |
vector< unsigned int > | _cumulative_size |
stored_type * | _storage |
Classes | |
class | Iterator |
The number of dimensions may be defined run-time, which should be the main cause to use this implementation instead of readily available ones. As a draw-back, the matrix can only be constructed when the matrix dimension sizes are already known. However, resizing the matrix is possible as long as the number of dimensions does not change.
The below-the-surface storage mechanism is a one-dimensional array, hence the name N(-dimensional)1DArray.
stored_type | The type of elements to-be stored. |
Definition at line 46 of file N1DArray.h.
N1DArray< stored_type >::N1DArray | ( | vector< unsigned int > | sizes | ) | [inline] |
The basic N1DArray constructor. Needs the exact dimension sizes.
sizes | The sizes of the individual dimensions. The number of dimensions is assumed to be the size of this vector. |
Definition at line 262 of file N1DArray.h.
References N1DArray< stored_type >::_cumulative_size, N1DArray< stored_type >::_dimension, N1DArray< stored_type >::_sizes, N1DArray< stored_type >::_storage, and N1DArray< stored_type >::size.
N1DArray< stored_type >::N1DArray | ( | unsigned int | x, | |
unsigned int | y, | |||
unsigned int | z, | |||
unsigned int | w | |||
) | [inline] |
Convenience constructor. Takes four arguments to create a 4D array with the individual dimension sizes given by those arguments.
x | The first dimension size | |
y | The second dimension size | |
z | The third dimension size | |
w | The fourth dimension size |
Definition at line 310 of file N1DArray.h.
N1DArray destructor. Deletes the 1-D storage array, but does not delete its contents!
Definition at line 322 of file N1DArray.h.
References N1DArray< stored_type >::_storage.
bool N1DArray< stored_type >::checkIndex | ( | vector< unsigned int > | index | ) | [inline, protected] |
Checks if a coordinate vector is valid.
Both checks the dimensions of the vector as well as the range of the index vector coordinates.
index | The index vector. |
Definition at line 88 of file N1DArray.h.
References N1DArray< stored_type >::_dimension, and N1DArray< stored_type >::_sizes.
Referenced by N1DArray< stored_type >::get1D().
Gets the iterator corresponding to the beginning element of the current N1DArray.
Definition at line 183 of file N1DArray.h.
Gets the iterator corresponding to one element past the last element of the current N1DArray.
Definition at line 194 of file N1DArray.h.
References N1DArray< stored_type >::size.
int N1DArray< stored_type >::get1D | ( | vector< unsigned int > | index | ) | [inline] |
Translates a multi-dimensional index vector to a 1-dimensional index parameter.
index | The index vector. |
Definition at line 206 of file N1DArray.h.
References N1DArray< stored_type >::_cumulative_size, N1DArray< stored_type >::_dimension, N1DArray< stored_type >::_sizes, N1DArray< stored_type >::checkIndex(), and N1DArray< stored_type >::size.
Referenced by N1DArray< stored_type >::get(), and N1DArray< stored_type >::set().
stored_type N1DArray< stored_type >::get | ( | vector< unsigned int > | index | ) | [inline] |
Gets the stored element at a given coordinate and returns it.
index | The index vector representing the coordinates. |
Definition at line 333 of file N1DArray.h.
References N1DArray< stored_type >::_storage, and N1DArray< stored_type >::get1D().
void N1DArray< stored_type >::set | ( | vector< unsigned int > | index, | |
stored_type | obj | |||
) | [inline] |
Stores a given element at a given coordinate.
index | The coordinates at which to store the element | |
obj | The element to be stored |
Definition at line 350 of file N1DArray.h.
References N1DArray< stored_type >::_storage, and N1DArray< stored_type >::get1D().
Referenced by N1DArray< stored_type >::resize().
void N1DArray< stored_type >::resize | ( | vector< unsigned int > | sizes | ) | [inline] |
Resizes the current matrix to dimensions subscribed by a new size vector. If the new size vectors are in any dimension smaller than previously, a warning is given AND NO RESIZING IS DONE WHATSOEVER. When the given sizes and the current sizes match in all dimensions, no resizing is done also. Resizing is an order n operation, where n is the size of the current 1D array used for storage.
sizes | A vector containing new sizes for all dimensions. |
Definition at line 386 of file N1DArray.h.
References N1DArray< stored_type >::_cumulative_size, N1DArray< stored_type >::_dimension, N1DArray< stored_type >::_sizes, N1DArray< stored_type >::_storage, N1DArray< stored_type >::resize(), N1DArray< stored_type >::set(), and N1DArray< stored_type >::size.
Referenced by N1DArray< stored_type >::resize().
The size of the one-dimensional array
Definition at line 65 of file N1DArray.h.
Referenced by N1DArray< stored_type >::end(), N1DArray< stored_type >::get1D(), N1DArray< stored_type >::N1DArray(), and N1DArray< stored_type >::resize().
unsigned int N1DArray< stored_type >::_dimension [protected] |
The number of dimensions of the matrix
Definition at line 68 of file N1DArray.h.
Referenced by N1DArray< stored_type >::checkIndex(), N1DArray< stored_type >::get1D(), N1DArray< stored_type >::N1DArray(), and N1DArray< stored_type >::resize().
The individual dimension sizes
Definition at line 71 of file N1DArray.h.
Referenced by N1DArray< stored_type >::checkIndex(), N1DArray< stored_type >::get1D(), N1DArray< stored_type >::N1DArray(), and N1DArray< stored_type >::resize().
vector< unsigned int > N1DArray< stored_type >::_cumulative_size [protected] |
Array used for quick N-D to 1-D index calculation
Definition at line 74 of file N1DArray.h.
Referenced by N1DArray< stored_type >::get1D(), N1DArray< stored_type >::N1DArray(), and N1DArray< stored_type >::resize().
The 1-D Array which does the actual storing
Definition at line 77 of file N1DArray.h.
Referenced by N1DArray< stored_type >::get(), N1DArray< stored_type >::N1DArray(), N1DArray< stored_type >::resize(), N1DArray< stored_type >::set(), and N1DArray< stored_type >::~N1DArray().