Warning: this documentation for the development version is under construction.

Seldon::Vector2< T, Allocator0, Allocator1 > Class Template Reference

Vector of vectors. More...

#include <Vector2.hxx>

List of all members.

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.
Vector< T, VectFull, Allocator0 > Flatten () const
 Returns all values in a vector.
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.
Vector2< T, Allocator0,
Allocator1 > 
Copy () const
 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.
void Write (string file_name, bool with_size=true) const
 Writes the instance in a binary file.
void Write (ostream &file_stream, bool with_size=true) const
 Writes the instance in a stream in a binary format.
void Read (string file_name, bool with_size=true)
 Reads the Vector2 from a file.
void Read (istream &file_stream, bool with_size=true)
 Reads the Vector2 from a file.

Protected Attributes

Vector< Vector< T, VectFull,
Allocator0 >, VectFull,
Allocator1 > 
data_

Detailed Description

template<class T, class Allocator0 = SELDON_VECTOR2_DEFAULT_ALLOCATOR_0<T>, class Allocator1 = SELDON_VECTOR2_DEFAULT_ALLOCATOR_1< Vector<T, VectFull, Allocator0> >>
class Seldon::Vector2< T, Allocator0, Allocator1 >

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.

Template Parameters:
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 60 of file Vector2.hxx.


Constructor & Destructor Documentation

template<class T , class Allocator0 , class Allocator1 >
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 (  ) 

Default constructor.

Nothing is allocated.

Definition at line 44 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 ( int  length  ) 

Constructor.

The vector of vectors is allocated with length empty vectors.

Parameters:
[in] length the length of the vector of vectors.

Definition at line 54 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Seldon::Vector2< T, Allocator0, Allocator1 >::Vector2 ( const Vector< int > &  length  ) 

Constructor.

The vector of vectors and the inner vectors are allocated.

Parameters:
[in] length the lengths of the inner vectors. The vector of vectors will obviously have as many elements as length has.

Definition at line 66 of file Vector2.cxx.


Member Function Documentation

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Clear ( int  i  ) 

Clears a given vector.

Parameters:
[in] i index of the vector to be cleared.

Definition at line 423 of file Vector2.cxx.

template<class T, class Allocator0, class Allocator1>
void Seldon::Vector2< T, Allocator0, Allocator1 >::Copy ( const Vector2< T, Allocator0, Allocator1 > &  V  ) 

Copies a Vector2 instance.

Parameters:
[in] V Vector2 instance to be copied.
Note:
The current instance and V do not share memory on exit: V is duplicated in memory.

Definition at line 499 of file Vector2.cxx.

template<class T, class Allocator0, class Allocator1>
Vector2< T, Allocator0, Allocator1 > Seldon::Vector2< T, Allocator0, Allocator1 >::Copy (  )  const

Copies a Vector2 instance.

Returns:
A copy of the current Vector2 instance.
Note:
The current instance and the copy do not share memory on exit.

Definition at line 515 of file Vector2.cxx.

template<class T, class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Fill ( const T &  x  ) 

Fills the vector with a given value.

Parameters:
[in] x value to fill the vector with.

Definition at line 434 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector< T, VectFull, Allocator0 > Seldon::Vector2< T, Allocator0, Allocator1 >::Flatten (  )  const

Returns all values in a vector.

The output vector contains all inner vectors concatenated in the same order as they appear in the current Vector2 instance.

Returns:
All values from the current Vector2 instance.

Definition at line 296 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
template<class Td , class Allocatord >
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.

Parameters:
[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 337 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
template<class Td , class Allocatord >
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.

Parameters:
[out] data all values from the current Vector2 instance.

Definition at line 315 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetLength ( int  i  )  const

Returns the size of the inner vector #i.

Parameters:
[in] i index.
Returns:
The size of the inner vector #i.

Definition at line 147 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetLength (  )  const

Returns the size along dimension 1.

Returns:
The size along dimension 1.

Definition at line 123 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
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.

Parameters:
[in] beg inclusive lower-bound for the indexes.
[in] end exclusive upper-bound for the indexes.
Returns:
The sum of the lengths of the inner vectors with index beg to end-1.

Definition at line 176 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetNelement (  )  const

Returns the total number of elements in the inner vectors.

Returns:
The sum of the lengths of the inner vectors.

Definition at line 158 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector< int > Seldon::Vector2< T, Allocator0, Allocator1 >::GetShape (  )  const

Returns the shape.

Returns:
A vector with the lengths of the inner vectors.

Definition at line 201 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::GetShape ( Vector< int > &  shape  )  const

Returns the shape.

Parameters:
[out] shape the lengths of the inner vectors.

Definition at line 215 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetSize ( int  i  )  const

Returns the size of the inner vector #i.

Parameters:
[in] i index.
Returns:
The size of the inner vector #i.

Definition at line 135 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
int Seldon::Vector2< T, Allocator0, Allocator1 >::GetSize (  )  const

Returns the size along dimension 1.

Returns:
The size along dimension 1.

Definition at line 112 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
const Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector ( int  i  )  const

Returns a given inner vector.

Parameters:
[in] i index of the inner vector.
Returns:
The inner vector #i.

Definition at line 485 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector (  ) 

Returns the vector of vectors.

Returns:
The vector of vectors.

Definition at line 447 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
const Vector< Vector< T, VectFull, Allocator0 >, VectFull, Allocator1 > Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector (  )  const

Returns the vector of vectors.

Returns:
The vector of vectors.

Definition at line 459 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::GetVector ( int  i  ) 

Returns a given inner vector.

Parameters:
[in] i index of the inner vector.
Returns:
The inner vector #i.

Definition at line 472 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
template<class V2 >
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.

Parameters:
[in] V Vector2 instance whose shape is compared to that of the current instance.
Returns:
True if the current instance as the same shape as V, false otherwise.

Definition at line 598 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
bool Seldon::Vector2< T, Allocator0, Allocator1 >::IsEmpty (  )  const

Checks whether no elements are contained in the inner vectors.

Returns:
True is no inner vector contains an element, false otherwise.

Definition at line 98 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
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.

Parameters:
[in] i index of the inner vector.
[in] j index of the element in the inner vector #i.
Returns:
The element #j of the inner vector #i.

Definition at line 562 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
const Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::operator() ( int  i  )  const

Returns a given inner vector.

Parameters:
[in] i index of the inner vector.
Returns:
The inner vector #i.

Definition at line 535 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector2< T, Allocator0, Allocator1 >::reference Seldon::Vector2< T, Allocator0, Allocator1 >::operator() ( int  i,
int  j 
)

Returns an element of a given inner vector.

Parameters:
[in] i index of the inner vector.
[in] j index of the element in the inner vector #i.
Returns:
The element #j of the inner vector #i.

Definition at line 576 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
Vector< T, VectFull, Allocator0 > & Seldon::Vector2< T, Allocator0, Allocator1 >::operator() ( int  i  ) 

Returns a given inner vector.

Parameters:
[in] i index of the inner vector.
Returns:
The inner vector #i.

Definition at line 548 of file Vector2.cxx.

template<class T, class Allocator0, class Allocator1>
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.

Parameters:
[in] V vector of vectors to be appended.

Definition at line 389 of file Vector2.cxx.

template<class T, class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack ( int  i,
const T &  x 
)

Appends an element at the end of the inner vector #i.

Parameters:
[in] i index of the inner vector to which x should be appended.
[in] x element to be appended.

Definition at line 364 of file Vector2.cxx.

template<class T, class Allocator0, class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::PushBack ( const Vector< T, VectFull, Allocator0 > &  X  ) 

Appends an inner vector at the end of the vector.

Parameters:
[in] X vector to be appended.

Definition at line 376 of file Vector2.cxx.

template<class T, class Allocator0, class Allocator1>
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.

Parameters:
[in] V vector of vectors to be appended.

Definition at line 404 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Read ( istream &  stream,
bool  with_size = true 
)

Reads the Vector2 from a file.

Sets the current Vector2 instance according to a binary stream that stores the total number of inner vectors, and, for each inner vector, the length of the vector (integer) and its elements.

Parameters:
[in,out] stream input stream.
[in] with_size if set to 'false', the total number of inner vectors and the lengths of the vectors are not available in the stream. In this case, the shape of the current instance is unchanged and the values of the elements are directly read in the file.

Definition at line 740 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Read ( string  file_name,
bool  with_size = true 
)

Reads the Vector2 from a file.

Sets the current Vector2 instance according to a binary file that stores the total number of inner vectors, and, for each inner vector, the length of the vector (integer) and its elements.

Parameters:
[in] file_name file name.
[in] with_size if set to 'false', the total number of inner vectors and the lengths of the vectors are not available in the file. In this case, the shape of the current instance is unchanged and the values of the elements are directly read in the file.

Definition at line 709 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate ( const Vector< int > &  length  ) 

Reallocates the whole structure.

Parameters:
[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 253 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate ( int  M  ) 

Reallocates the vector of vector.

Parameters:
[in] M the new size of the vector of vectors.

Definition at line 228 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Reallocate ( int  i,
int  N 
)

Reallocates the inner vector #i.

Parameters:
[in] i index of the inner vector to be reallocated.
[in] N the new size of the inner vector #i.

Definition at line 240 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
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.

Parameters:
[in] beg inclusive lower-bound for the indexes.
[in] end exclusive upper-bound for the indexes.

Definition at line 269 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Write ( string  file_name,
bool  with_size = true 
) const

Writes the instance in a binary file.

The number of inner vectors (integer) is written first. Then for each vector, the length of the vector (integer) and all elements of the vector are written.

Parameters:
[in] file_name file name.
[in] with_size if set to 'false', the number of vectors and the lengths of the inner vectors are not saved.

Definition at line 637 of file Vector2.cxx.

template<class T , class Allocator0 , class Allocator1 >
void Seldon::Vector2< T, Allocator0, Allocator1 >::Write ( ostream &  stream,
bool  with_size = true 
) const

Writes the instance in a stream in a binary format.

The number of inner vectors (integer) is written first. Then for each vector, the length of the vector (integer) and all elements of the vector are written.

Parameters:
[in,out] stream output stream.
[in] with_size if set to 'false', the number of vectors and the lengths of the inner vectors are not saved.

Definition at line 666 of file Vector2.cxx.


The documentation for this class was generated from the following files:
  • /home/vivien/public_html/.src_seldon/vector/Vector2.hxx
  • /home/vivien/public_html/.src_seldon/vector/Vector2.cxx