HyperspaceExplorer 0.7.1
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
VecMath::MultiDimensionalVector< T, D > Class Template Reference

A D -dimensionally nested std::vector of objects of type T. More...

#include <MultiDimensionalVector.h>

Inheritance diagram for VecMath::MultiDimensionalVector< T, D >:
Inheritance graph
[legend]
Collaboration diagram for VecMath::MultiDimensionalVector< T, D >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector
< MultiDimensionalVector< T, D-1 >
>::iterator 
iterator
 Iterator type to loop over elements, read/write - from std::vector.
typedef std::vector
< MultiDimensionalVector< T, D-1 >
>::const_iterator 
const_iterator
 Iterator type to loop over elements, read only - from std::vector.

Public Member Functions

 MultiDimensionalVector ()
 Construct an empty MultiDimensionalVector.
 MultiDimensionalVector (unsigned n)
 Construct an MultiDimensionalVector with n empty elements.
 MultiDimensionalVector (typename std::vector< MultiDimensionalVector< T, D-1 > >::iterator first, typename std::vector< MultiDimensionalVector< T, D-1 > >::iterator last)
 Construct a MultiDimensionalVector from an iterator range.
 MultiDimensionalVector (const MultiDimensionalVector< T, D > &v)
 Copy construct a MultiDimensionalVector.
 MultiDimensionalVector (MultiDimensionalVector< T, D > &&other)
MultiDimensionalVectoroperator= (const MultiDimensionalVector< T, D > &other)
MultiDimensionalVectoroperator= (MultiDimensionalVector< T, D > &&other)
iterator begin ()
 Iterator that points to the first element in the vector.
iterator end ()
 Iterator that points one past the last element in the vector.
const_iterator begin () const
 Read-only iterator that points to the first element in the vector.
const_iterator end () const
 Read-only iterator that points one past the last element in the vector.
void push_back (const MultiDimensionalVector< T, D-1 > &x)
 Add data to the end of the vector.
MultiDimensionalVector< T, D-1 > & back ()
 Returns a read/write reference to the data at the last element of the vector.
const MultiDimensionalVector
< T, D-1 > & 
back () const
 Returns a read-only (constant) reference to the data at the last element of the vector.
iterator erase (iterator position)
 Remove element at given position.
iterator erase (iterator first, iterator last)
 Remove elements at given range.
MultiDimensionalVector< T, D-1 > & operator[] (unsigned i)
 Subscript access to the data contained in the vector.
const MultiDimensionalVector
< T, D-1 > & 
operator[] (unsigned i) const
 Subscript access to the data contained in the vector.
unsigned size () const
 Returns the number of elements in the vector.
unsigned empty () const
 Returns true if the vector is empty. (Thus begin() would equal end().)
void clear ()
 Erases all the elements, and calls clear() on them recursively.
void resize (unsigned new_size)
 Resizes the vector to the specified number of elements.
void resize (unsigned new_size, MultiDimensionalVector< T, D-1 > x)
 Resizes the vector to the specified number of elements.
void reserve (unsigned new_size)
 Attempt to preallocate enough memory for specified number of elements.
bool operator== (const MultiDimensionalVector< T, D > &other) const
 Returns true if other is not equal to this.
bool operator!= (const MultiDimensionalVector< T, D > &other) const
 Returns true if other is not equal to this.
template<typename Function >
Function for_each (Function f)
 Apply a function or functor on every element of a MultiDimensionalVector.
template<typename Function >
Function for_each (Function f) const
 Apply a function or functor on every element of a MultiDimensionalVector.
std::string toString () const
 Convert NestedVector to a std::string.
void print () const
 Prints the elements of the vector.

Protected Member Functions

std::vector
< MultiDimensionalVector< T, D-1 > > & 
data ()
 Access to the stored vector.
const std::vector
< MultiDimensionalVector< T, D-1 > > & 
data () const
 Read-only access to the stored vector.

Private Attributes

std::vector
< MultiDimensionalVector< T, D-1 > > 
_data
 A std::vector of dimensionality D - 1.

Detailed Description

template<typename T, unsigned D>
class VecMath::MultiDimensionalVector< T, D >

A D -dimensionally nested std::vector of objects of type T.

As always, an example is more illustrative than a lengthy description:

    MultiDimensionalVector<unsigned, 1> v1;
    v[i] = 1;
    MultiDimensionalVector<double, 2> v2;
    v[i][j] = 1.0;
    MultiDimensionalVector<std::string, 4> v4;
    v[i][j][k][l] = "hello, world!";

This class emulates the std::vector interface to the extent that it is used in HyperspaceExplorer. It does not inherit from std::vector, but it behaves like one.

Template Parameters:
TType that is eventually stored
DDimensionality (nesting depth) of the vector
Author:
Lene Preuss <lene.preuss@gmail.com>

Member Function Documentation

template<typename T , unsigned D>
MultiDimensionalVector< T, D >::iterator VecMath::MultiDimensionalVector< T, D >::erase ( iterator  position)

Remove element at given position.

Parameters:
positionIterator pointing to element to be erased
Returns:
An iterator pointing to the next element (or end())

Referenced by AltSponge::Initialize().

Here is the caller graph for this function:

template<typename T , unsigned D>
MultiDimensionalVector< T, D >::iterator VecMath::MultiDimensionalVector< T, D >::erase ( iterator  first,
iterator  last 
)

Remove elements at given range.

Parameters:
firstIterator pointing to first element to be erased
lastIterator pointing to one past the last element to be erased.
Returns:
An iterator pointing to the next element (or end())
template<typename T , unsigned D>
template<typename Function >
Function VecMath::MultiDimensionalVector< T, D >::for_each ( Function  f)

Apply a function or functor on every element of a MultiDimensionalVector.

Template Parameters:
FunctionA unary function object or function taking a T, const T& or T& as argument type.

References begin(), and end().

Referenced by VecMath::MultiDimensionalVector< T, 1 >::for_each().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T, unsigned D>
bool VecMath::MultiDimensionalVector< T, D >::operator!= ( const MultiDimensionalVector< T, D > &  other) const

Returns true if other is not equal to this.

Parameters:
otherNestedVector<T, D> to compare to

References VecMath::MultiDimensionalVector< T, D >::data().

Here is the call graph for this function:

template<typename T, unsigned D>
bool VecMath::MultiDimensionalVector< T, D >::operator== ( const MultiDimensionalVector< T, D > &  other) const

Returns true if other is not equal to this.

Parameters:
otherNestedVector<T, D> to compare to

References VecMath::MultiDimensionalVector< T, D >::data().

Here is the call graph for this function:

template<typename T , unsigned D>
const MultiDimensionalVector< T, D-1 > & VecMath::MultiDimensionalVector< T, D >::operator[] ( unsigned  i) const

Subscript access to the data contained in the vector.

Parameters:
iThe index of the element for which data should be accessed
Returns:
Read-only (constant) reference to data.
template<typename T , unsigned D>
MultiDimensionalVector< T, D-1 > & VecMath::MultiDimensionalVector< T, D >::operator[] ( unsigned  i)

Subscript access to the data contained in the vector.

Parameters:
iThe index of the element for which data should be accessed
Returns:
Read/write reference to data.
template<typename T, unsigned D>
void VecMath::MultiDimensionalVector< T, D >::push_back ( const MultiDimensionalVector< T, D-1 > &  x)

Add data to the end of the vector.

Parameters:
xData to be added

Referenced by AltSponge::Initialize(), rotate_base< D >::rotate_line(), rotate_base< D >::rotate_quad(), and rotate_base< D >::rotate_triangle().

Here is the caller graph for this function:

template<typename T , unsigned D>
void VecMath::MultiDimensionalVector< T, D >::reserve ( unsigned  new_size)

Attempt to preallocate enough memory for specified number of elements.

Parameters:
new_sizeNumber of elements the vector should contain
template<typename T, unsigned D>
void VecMath::MultiDimensionalVector< T, D >::resize ( unsigned  new_size,
MultiDimensionalVector< T, D-1 >  x 
)

Resizes the vector to the specified number of elements.

Parameters:
new_sizeNumber of elements the vector should contain
xData with which new elements should be populated
template<typename T , unsigned D>
void VecMath::MultiDimensionalVector< T, D >::resize ( unsigned  new_size)

Resizes the vector to the specified number of elements.

Parameters:
new_sizeNumber of elements the vector should contain

Referenced by AltSponge::Initialize().

Here is the caller graph for this function:


Member Data Documentation

template<typename T, unsigned D>
std::vector<MultiDimensionalVector<T, D-1> > VecMath::MultiDimensionalVector< T, D >::_data [private]

A std::vector of dimensionality D - 1.

All operations are delegated to this vector.

Referenced by VecMath::MultiDimensionalVector< T, 1 >::data().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:19 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo