|
HyperspaceExplorer 0.7.1
|
A D -dimensionally nested std::vector of objects of type T.
More...
#include <MultiDimensionalVector.h>


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) | |
| MultiDimensionalVector & | operator= (const MultiDimensionalVector< T, D > &other) |
| MultiDimensionalVector & | operator= (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. | |
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.
| T | Type that is eventually stored |
| D | Dimensionality (nesting depth) of the vector |
| MultiDimensionalVector< T, D >::iterator VecMath::MultiDimensionalVector< T, D >::erase | ( | iterator | position | ) |
Remove element at given position.
| position | Iterator pointing to element to be erased |
Referenced by AltSponge::Initialize().

| MultiDimensionalVector< T, D >::iterator VecMath::MultiDimensionalVector< T, D >::erase | ( | iterator | first, |
| iterator | last | ||
| ) |
Remove elements at given range.
| first | Iterator pointing to first element to be erased |
| last | Iterator pointing to one past the last element to be erased. |
| Function VecMath::MultiDimensionalVector< T, D >::for_each | ( | Function | f | ) |
Apply a function or functor on every element of a MultiDimensionalVector.
| Function | A 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().


| bool VecMath::MultiDimensionalVector< T, D >::operator!= | ( | const MultiDimensionalVector< T, D > & | other | ) | const |
Returns true if other is not equal to this.
| other | NestedVector<T, D> to compare to |
References VecMath::MultiDimensionalVector< T, D >::data().

| bool VecMath::MultiDimensionalVector< T, D >::operator== | ( | const MultiDimensionalVector< T, D > & | other | ) | const |
Returns true if other is not equal to this.
| other | NestedVector<T, D> to compare to |
References VecMath::MultiDimensionalVector< T, D >::data().

| const MultiDimensionalVector< T, D-1 > & VecMath::MultiDimensionalVector< T, D >::operator[] | ( | unsigned | i | ) | const |
Subscript access to the data contained in the vector.
| i | The index of the element for which data should be accessed |
| MultiDimensionalVector< T, D-1 > & VecMath::MultiDimensionalVector< T, D >::operator[] | ( | unsigned | i | ) |
Subscript access to the data contained in the vector.
| i | The index of the element for which data should be accessed |
| void VecMath::MultiDimensionalVector< T, D >::push_back | ( | const MultiDimensionalVector< T, D-1 > & | x | ) |
Add data to the end of the vector.
| x | Data to be added |
Referenced by AltSponge::Initialize(), rotate_base< D >::rotate_line(), rotate_base< D >::rotate_quad(), and rotate_base< D >::rotate_triangle().

| void VecMath::MultiDimensionalVector< T, D >::reserve | ( | unsigned | new_size | ) |
Attempt to preallocate enough memory for specified number of elements.
| new_size | Number of elements the vector should contain |
| void VecMath::MultiDimensionalVector< T, D >::resize | ( | unsigned | new_size, |
| MultiDimensionalVector< T, D-1 > | x | ||
| ) |
Resizes the vector to the specified number of elements.
| new_size | Number of elements the vector should contain |
| x | Data with which new elements should be populated |
| void VecMath::MultiDimensionalVector< T, D >::resize | ( | unsigned | new_size | ) |
Resizes the vector to the specified number of elements.
| new_size | Number of elements the vector should contain |
Referenced by AltSponge::Initialize().

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().
1.7.4
-
Hosted by