Vector of vectors. More...
#include <Vector2.hxx>
Public Types | |
typedef T | value_type |
typedef T * | pointer |
typedef const T * | const_pointer |
typedef T & | reference |
typedef const T & | const_reference |
Public Member Functions | |
Vector2 () | |
Default constructor. | |
Vector2 (int length) | |
Constructor. | |
Vector2 (const Vector< int > &length) | |
Constructor. | |
~Vector2 () | |
Destructor. The vector of vectors and the inner vectors are deallocated. | |
bool | IsEmpty () const |
Checks whether no elements are contained in the inner vectors. | |
int | GetLength () const |
Returns the size along dimension 1. | |
int | GetSize () const |
Returns the size along dimension 1. | |
int | GetLength (int i) const |
Returns the size of the inner vector #i. | |
int | GetSize (int i) const |
Returns the size of the inner vector #i. | |
int | GetNelement () const |
Returns the total number of elements in the inner vectors. | |
int | GetNelement (int beg, int end) const |
Returns the total number of elements in a range of inner vectors. | |
Vector< int > | GetShape () const |
Returns the shape. | |
void | GetShape (Vector< int > &shape) const |
Returns the shape. | |
void | Reallocate (int M) |
Reallocates the vector of vector. | |
void | Reallocate (int i, int N) |
Reallocates the inner vector #i. | |
void | Reallocate (const Vector< int > &length) |
Reallocates the whole structure. | |
void | Select (int beg, int end) |
Selects a range of inner vectors. | |
template<class Td , class Allocatord > | |
void | Flatten (Vector< Td, VectFull, Allocatord > &data) const |
Returns all values in a vector. | |
template<class Td , class Allocatord > | |
void | Flatten (int beg, int end, Vector< Td, VectFull, Allocatord > &data) const |
Returns in a vector all values from a range of inner vectors. | |
void | PushBack (int i, const T &x) |
Appends an element at the end of the inner vector #i. | |
void | PushBack (const Vector< T, VectFull, Allocator0 > &X) |
Appends an inner vector at the end of the vector. | |
void | PushBack (const Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > &V) |
Appends a vector of vectors. | |
void | PushBack (const Vector2< T, Allocator0, Allocator1 > &V) |
Appends a vector of vectors. | |
void | Clear () |
Clears the vector. | |
void | Clear (int i) |
Clears a given vector. | |
void | Fill (const T &x) |
Fills the vector with a given value. | |
Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > & | GetVector () |
Returns the vector of vectors. | |
const Vector< Vector< T, VectFull, Allocator0 > , VectFull, Allocator1 > | GetVector () const |
Returns the vector of vectors. | |
Vector< T, VectFull, Allocator0 > & | GetVector (int i) |
Returns a given inner vector. | |
const Vector< T, VectFull, Allocator0 > & | GetVector (int i) const |
Returns a given inner vector. | |
void | Copy (const Vector2< T, Allocator0, Allocator1 > &V) |
Copies a Vector2 instance. | |
const Vector< T, VectFull, Allocator0 > & | operator() (int i) const |
Returns a given inner vector. | |
Vector< T, VectFull, Allocator0 > & | operator() (int i) |
Returns a given inner vector. | |
const_reference | operator() (int i, int j) const |
Returns an element of a given inner vector. | |
reference | operator() (int i, int j) |
Returns an element of a given inner vector. | |
template<class V2 > | |
bool | HasSameShape (const V2 &V) const |
Checks whether another Vector2 instance has the same shape. | |
void | Print () const |
Displays the vector. | |
Protected Attributes | |
Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > | data_ |
Vector of vectors.
Vector2 is a structure that acts like a vector of vectors. The inner vectors can be of any dimension, so that this structure is more flexible than a matrix.
T | numerical type of the inner vectors. | |
Allocator0 | allocator for the inner vectors. The default allocator is SELDON_DEFAULT_ALLOCATOR. | |
Allocator1 | allocator for the vector of vectors. It is recommended to choose NewAlloc or, for more efficient in reallocations, MallocObject (default allocator here): these allocators can manage an array of inner vectors. |
Definition at line 59 of file Vector2.hxx.
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 | ( | ) |
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 | ( | int | length | ) |
Constructor.
The vector of vectors is allocated with length empty vectors.
[in] | length | the length of the vector of vectors. |
Definition at line 53 of file Vector2.cxx.
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 | ( | const Vector< int > & | length | ) |
Constructor.
The vector of vectors and the inner vectors are allocated.
[in] | length | the lengths of the inner vectors. The vector of vectors will obviously have as many elements as length has. |
Definition at line 65 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Clear | ( | int | i | ) |
Clears a given vector.
[in] | i | index of the vector to be cleared. |
Definition at line 404 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Copy | ( | const Vector2< T, Allocator0, Allocator1 > & | V | ) |
Copies a Vector2 instance.
[in] | V | Vector2 instance to be copied. |
Definition at line 480 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Fill | ( | const T & | x | ) |
Fills the vector with a given value.
[in] | x | value to fill the vector with. |
Definition at line 415 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Flatten | ( | Vector< Td, VectFull, Allocatord > & | data | ) | const |
Returns all values in a vector.
The output vector data contains all inner vectors concatenated in the same order as they appear in the current Vector2 instance.
[out] | data | all values from the current Vector2 instance. |
Definition at line 296 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Flatten | ( | int | beg, | |
int | end, | |||
Vector< Td, VectFull, Allocatord > & | data | |||
) | const |
Returns in a vector all values from a range of inner vectors.
The output vector data contains all inner vectors, in the index range [beg, end[, concatenated in the same order as they appear in the current Vector2 instance.
[in] | beg | inclusive lower-bound for the indexes. |
[in] | end | exclusive upper-bound for the indexes. |
[out] | data | the values contained in the inner vectors [beg, end[. |
Definition at line 318 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetLength | ( | int | i | ) | const |
Returns the size of the inner vector #i.
[in] | i | index. |
Definition at line 146 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetLength | ( | ) | const |
Returns the size along dimension 1.
Definition at line 122 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetNelement | ( | int | beg, | |
int | end | |||
) | const |
Returns the total number of elements in a range of inner vectors.
Returns the total number of elements in the range [beg, end[ of inner vectors.
[in] | beg | inclusive lower-bound for the indexes. |
[in] | end | exclusive upper-bound for the indexes. |
Definition at line 175 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetNelement | ( | ) | const |
Returns the total number of elements in the inner vectors.
Definition at line 157 of file Vector2.cxx.
Vector< int > Seldon::Vector2< T, Allocator0, Allocator1 >::GetShape | ( | ) | const |
Returns the shape.
Definition at line 200 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::GetShape | ( | Vector< int > & | shape | ) | const |
Returns the shape.
[out] | shape | the lengths of the inner vectors. |
Definition at line 214 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetSize | ( | int | i | ) | const |
Returns the size of the inner vector #i.
[in] | i | index. |
Definition at line 134 of file Vector2.cxx.
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetSize | ( | ) | const |
Returns the size along dimension 1.
Definition at line 111 of file Vector2.cxx.
Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector | ( | ) |
Returns the vector of vectors.
Definition at line 428 of file Vector2.cxx.
Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector | ( | int | i | ) |
Returns a given inner vector.
[in] | i | index of the inner vector. |
Definition at line 453 of file Vector2.cxx.
const Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector | ( | ) | const |
Returns the vector of vectors.
Definition at line 440 of file Vector2.cxx.
const Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector | ( | int | i | ) | const |
Returns a given inner vector.
[in] | i | index of the inner vector. |
Definition at line 466 of file Vector2.cxx.
bool Seldon::Vector2< T, Allocator0, Allocator1 >::HasSameShape | ( | const V2 & | V | ) | const |
Checks whether another Vector2 instance has the same shape.
Checks whether another Vector2 instance has the same shape as the current instance. The shapes are the same if both instances have the same number of inner vectors, and if the inner vectors have the same lengths.
[in] | V | Vector2 instance whose shape is compared to that of the current instance. |
Definition at line 564 of file Vector2.cxx.
bool Seldon::Vector2< T, Allocator0, Allocator1 >::IsEmpty | ( | ) | const |
Checks whether no elements are contained in the inner vectors.
Definition at line 97 of file Vector2.cxx.
const Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::operator() | ( | int | i | ) | const |
Returns a given inner vector.
[in] | i | index of the inner vector. |
Definition at line 501 of file Vector2.cxx.
Vector2< T, Allocator0, Allocator1 >::const_reference Seldon::Vector2< T, Allocator0, Allocator1 >::operator() | ( | int | i, | |
int | j | |||
) | const |
Returns an element of a given inner vector.
[in] | i | index of the inner vector. |
[in] | j | index of the element in the inner vector #i. |
Definition at line 528 of file Vector2.cxx.
Vector2< T, Allocator0, Allocator1 >::reference Seldon::Vector2< T, Allocator0, Allocator1 >::operator() | ( | int | i, | |
int | j | |||
) |
Returns an element of a given inner vector.
[in] | i | index of the inner vector. |
[in] | j | index of the element in the inner vector #i. |
Definition at line 542 of file Vector2.cxx.
Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::operator() | ( | int | i | ) |
Returns a given inner vector.
[in] | i | index of the inner vector. |
Definition at line 514 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack | ( | const Vector< T, VectFull, Allocator0 > & | X | ) |
Appends an inner vector at the end of the vector.
[in] | X | vector to be appended. |
Definition at line 357 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack | ( | const Vector2< T, Allocator0, Allocator1 > & | V | ) |
Appends a vector of vectors.
The inner vectors of V are appended to the current instance, in the same order as they appear in V.
[in] | V | vector of vectors to be appended. |
Definition at line 385 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack | ( | int | i, | |
const T & | x | |||
) |
Appends an element at the end of the inner vector #i.
[in] | i | index of the inner vector to which x should be appended. |
[in] | x | element to be appended. |
Definition at line 345 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack | ( | const Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > & | V | ) |
Appends a vector of vectors.
The inner vectors of V are appended to the current instance, in the same order as they appear in V.
[in] | V | vector of vectors to be appended. |
Definition at line 370 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate | ( | const Vector< int > & | length | ) |
Reallocates the whole structure.
[in] | length | the new lengths of the inner vectors. The vector of vectors will obviously have as many elements as length has. |
Definition at line 252 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate | ( | int | M | ) |
Reallocates the vector of vector.
[in] | M | the new size of the vector of vectors. |
Definition at line 227 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate | ( | int | i, | |
int | N | |||
) |
Reallocates the inner vector #i.
[in] | i | index of the inner vector to be reallocated. |
[in] | N | the new size of the inner vector #i. |
Definition at line 239 of file Vector2.cxx.
void Seldon::Vector2< T, Allocator0, Allocator1 >::Select | ( | int | beg, | |
int | end | |||
) |
Selects a range of inner vectors.
Only the inner vectors with index in [beg, end[ are kept. The other vectors are destroyed.
[in] | beg | inclusive lower-bound for the indexes. |
[in] | end | exclusive upper-bound for the indexes. |
Definition at line 268 of file Vector2.cxx.