N1DArray< stored_type > Class Template Reference

#include <N1DArray.h>

Collaboration diagram for N1DArray< stored_type >:

Collaboration graph
[legend]
List of all members.

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

Detailed Description

template<typename stored_type>
class N1DArray< stored_type >

A templated Multi-dimensional matrix which may store any object.

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.

Parameters:
stored_type The type of elements to-be stored.

Definition at line 46 of file N1DArray.h.


Constructor & Destructor Documentation

template<typename stored_type>
N1DArray< stored_type >::N1DArray ( vector< unsigned int >  sizes  )  [inline]

The basic N1DArray constructor. Needs the exact dimension sizes.

Parameters:
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.

template<typename stored_type>
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.

Parameters:
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.

template<typename stored_type>
N1DArray< stored_type >::~N1DArray (  )  [inline]

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.


Member Function Documentation

template<typename stored_type>
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.

Parameters:
index The index vector.
Returns:
A boolean indicating whether or not the supplied coordinate was valid.

Definition at line 88 of file N1DArray.h.

References N1DArray< stored_type >::_dimension, and N1DArray< stored_type >::_sizes.

Referenced by N1DArray< stored_type >::get1D().

template<typename stored_type>
Iterator N1DArray< stored_type >::begin (  )  [inline]

Gets the iterator corresponding to the beginning element of the current N1DArray.

Returns:
The requested Iterator

Definition at line 183 of file N1DArray.h.

template<typename stored_type>
Iterator N1DArray< stored_type >::end (  )  [inline]

Gets the iterator corresponding to one element past the last element of the current N1DArray.

Returns:
The requested Iterator

Definition at line 194 of file N1DArray.h.

References N1DArray< stored_type >::size.

template<typename stored_type>
int N1DArray< stored_type >::get1D ( vector< unsigned int >  index  )  [inline]

Translates a multi-dimensional index vector to a 1-dimensional index parameter.

Parameters:
index The index vector.
Returns:
The one-dimensional index.

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().

template<typename stored_type>
stored_type N1DArray< stored_type >::get ( vector< unsigned int >  index  )  [inline]

Gets the stored element at a given coordinate and returns it.

Parameters:
index The index vector representing the coordinates.
Returns:
The requested element.

Definition at line 333 of file N1DArray.h.

References N1DArray< stored_type >::_storage, and N1DArray< stored_type >::get1D().

template<typename stored_type>
void N1DArray< stored_type >::set ( vector< unsigned int >  index,
stored_type  obj 
) [inline]

Stores a given element at a given coordinate.

Parameters:
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().

template<typename stored_type>
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.

Parameters:
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().


Member Data Documentation

template<typename stored_type>
unsigned int N1DArray< stored_type >::size [protected]

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().

template<typename stored_type>
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().

template<typename stored_type>
vector< unsigned int > N1DArray< stored_type >::_sizes [protected]

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().

template<typename stored_type>
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().

template<typename stored_type>
stored_type* N1DArray< stored_type >::_storage [protected]

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().


The documentation for this class was generated from the following file:
Generated on Sat Oct 13 17:34:43 2007 for R-Tree by  doxygen 1.5.2