Seldon::Vector< T, Collection, Allocator > Class Template Reference

Structure for distributed vectors. More...

#include <VectorCollection.hxx>

Inheritance diagram for Seldon::Vector< T, Collection, Allocator >:
Seldon::Vector_Base< T, Allocator >

List of all members.

Public Types

typedef T::value_type value_type
typedef T::pointer pointer
typedef T::const_pointer const_pointer
typedef T::reference reference
typedef T::const_reference const_reference
typedef T vector_type
typedef vector_type * vector_pointer
typedef const vector_type * const_vector_pointer
typedef vector_type & vector_reference
typedef const vector_type & const_vector_reference
typedef Vector< vector_type,
VectFull, NewAlloc
< vector_type > > 
collection_type
typedef const collection_type const_collection_type
typedef collection_typecollection_reference
typedef const collection_typeconst_collection_reference
typedef Collection storage

Public Member Functions

 Vector ()
 Methods.
 Vector (int i)
 Main constructor.
 Vector (const Vector< T, Collection, Allocator > &A)
 Copy constructor.
 ~Vector ()
 Destructor.
void Clear ()
 Clears the vector collection.
void Reallocate (int i)
 Reallocates the vector collection.
void Deallocate ()
 Clears the vector collection.
template<class T0 , class Storage0 , class Allocator0 >
void AddVector (const Vector< T0, Storage0, Allocator0 > &vector)
 Adds a vector to the list of vectors.
template<class T0 , class Storage0 , class Allocator0 >
void AddVector (const Vector< T0, Storage0, Allocator0 > &vector, string name)
 Adds a vector to the list of vectors.
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (int i, const Vector< T0, Storage0, Allocator0 > &vector)
 Sets a vector in the list of vectors.
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (int i, const Vector< T0, Storage0, Allocator0 > &vector, string name)
 Sets a vector in the list of vectors.
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (string name, const Vector< T0, Storage0, Allocator0 > &vector)
 Sets a vector in the list of vectors.
void SetName (int i, string name)
 Sets the name of a given underlying vector.
void SetData (const Vector< T, Collection, Allocator > &X)
 Changes the length of the collection and sets its data array.
void Nullify ()
 Nullifies vectors of the collection without memory deallocation.
int GetM () const
 Returns the total number of elements.
int GetLength () const
 Returns the total number of elements.
int GetNvector () const
 Returns the number of aggregated vectors.
const Vector< int, VectFull,
MallocAlloc< int > > & 
GetVectorLength () const
 Returns the length vector of the underlying vectors.
const Vector< int, VectFull,
MallocAlloc< int > > & 
GetLengthSum () const
 Returns the cumulative sum of the lengths of the underlying vectors.
int GetVectorIndex (string name) const
 Returns the vector index of the aggregated vector named name.
int GetIndex (string name) const
 Returns the index of the first element of the aggregated vector named name.
collection_reference GetVector ()
 Returns the list of vectors.
const_collection_reference GetVector () const
 Returns the list of vectors.
vector_reference GetVector (int i)
 Returns one of the aggregated vectors.
const_vector_reference GetVector (int i) const
 Returns one of the aggregated vectors.
vector_reference GetVector (string name)
 Returns one of the aggregated vectors.
const_vector_reference GetVector (string name) const
 Returns one of the aggregated vectors.
const_reference operator() (int i) const
 Access operator.
reference operator() (int i)
 Access operator.
Vector< T, Collection,
Allocator > & 
operator= (const Vector< T, Collection, Allocator > &X)
 Duplicates a vector collection (assignment operator).
void Copy (const Vector< T, Collection, Allocator > &X)
 Duplicates a vector collection.
template<class T0 , class Allocator0 >
void Copy (const Vector< T0, VectFull, Allocator0 > &X)
 Copies the values of a full vector into the current vector.
template<class T0 >
Vector< T, Collection,
Allocator > & 
operator*= (const T0 &X)
 Multiplies a vector collection by a scalar.
template<class T0 >
void Fill (const T0 &x)
 Fills the collection with a given value.
void Print () const
 Displays the vector.
void Write (string FileName, bool with_size=true) const
 Writes the inner vectors in a file.
void Write (ostream &FileStream, bool with_size=true) const
 Writes the vector in a file stream.
void WriteText (string FileName) const
 Writes the vector in a file.
void WriteText (ostream &FileStream) const
 Writes the vector in a file stream.
void Read (string FileName, Vector< int, VectFull, MallocAlloc< int > > &length_)
 Sets the vector from a file.
void Read (istream &FileStream, Vector< int, VectFull, MallocAlloc< int > > &length_)
 Sets the vector from a file stream.
int GetSize () const
 Returns the number of elements stored.
pointer GetData () const
 Returns a pointer to data_ (stored data).
const_pointer GetDataConst () const
 Returns a const pointer to data_ (stored data).
void * GetDataVoid () const
 Returns a pointer of type "void*" to the data array (data_).
const void * GetDataConstVoid () const
 Returns a pointer of type "const void*" to the data array (data_).

Protected Attributes

int Nvector_
Vector< int, VectFull,
MallocAlloc< int > > 
length_
Vector< int, VectFull,
MallocAlloc< int > > 
length_sum_
collection_type vector_
map< string, int > label_map_
 Indexes of the inner vectors that have a name.
vector< string > label_vector_
 Names associated with the inner vectors.
int m_
pointer data_

Static Protected Attributes

static Allocator vect_allocator_

Detailed Description

template<class T, class Allocator>
class Seldon::Vector< T, Collection, Allocator >

Structure for distributed vectors.

Definition at line 38 of file VectorCollection.hxx.


Constructor & Destructor Documentation

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::Vector (  )  [inline, explicit]

Methods.

Default constructor.

Nothing is allocated. The vector length is set to zero.

Definition at line 46 of file VectorCollection.cxx.

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::Vector ( int  i  )  [explicit]

Main constructor.

Builds a vector collection of a given size.

Parameters:
[in] i length of the vector.

Definition at line 58 of file VectorCollection.cxx.

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::Vector ( const Vector< T, Collection, Allocator > &  V  ) 

Copy constructor.

Builds a copy of a vector collection.

Parameters:
[in] V vector collection to be copied.

Definition at line 74 of file VectorCollection.cxx.

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::~Vector (  )  [inline]

Destructor.

The inner vectors are nullified so that their memory blocks should not be deallocated.

Definition at line 91 of file VectorCollection.cxx.


Member Function Documentation

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::AddVector ( const Vector< T0, Storage0, Allocator0 > &  vector  ) 

Adds a vector to the list of vectors.

The vector is "appended" to the existing data.

Parameters:
[in] vector vector to be appended.

Definition at line 167 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::AddVector ( const Vector< T0, Storage0, Allocator0 > &  vector,
string  name 
)

Adds a vector to the list of vectors.

The vector is "appended" to the existing data.

Parameters:
[in] vector vector to be appended.
[in] name name of the vector to be appended.

Definition at line 198 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Clear (  )  [inline]

Clears the vector collection.

The inner vectors are nullified so that their memory blocks should not be deallocated.

Definition at line 105 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Copy ( const Vector< T, Collection, Allocator > &  X  )  [inline]

Duplicates a vector collection.

Parameters:
[in] X vector collection to be copied.
Note:
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 586 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::Copy ( const Vector< T0, VectFull, Allocator0 > &  X  )  [inline]

Copies the values of a full vector into the current vector.

Parameters:
[in] X full vector to be copied.
Note:
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 605 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Deallocate (  )  [inline]

Clears the vector collection.

The inner vectors are cleared and the memory blocks are deallocated.

Definition at line 141 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 >
void Seldon::Vector< T, Collection, Allocator >::Fill ( const T0 &  x  ) 

Fills the collection with a given value.

Parameters:
x value to fill the collection with.

Definition at line 647 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector_Base< T, Allocator >::pointer Seldon::Vector_Base< T, Allocator >::GetData (  )  const [inherited]

Returns a pointer to data_ (stored data).

Returns:
A pointer to the data_, i.e. the data array.

Definition at line 156 of file Vector.cxx.

template<class T , class Allocator >
Vector_Base< T, Allocator >::const_pointer Seldon::Vector_Base< T, Allocator >::GetDataConst (  )  const [inherited]

Returns a const pointer to data_ (stored data).

Returns:
A const pointer to the data_, i.e. the data array.

Definition at line 168 of file Vector.cxx.

template<class T , class Allocator >
const void * Seldon::Vector_Base< T, Allocator >::GetDataConstVoid (  )  const [inherited]

Returns a pointer of type "const void*" to the data array (data_).

Returns:
A pointer of type "const void*" to the data array.

Definition at line 191 of file Vector.cxx.

template<class T , class Allocator >
void * Seldon::Vector_Base< T, Allocator >::GetDataVoid (  )  const [inherited]

Returns a pointer of type "void*" to the data array (data_).

Returns:
A pointer of type "void*" to the data array.

Definition at line 180 of file Vector.cxx.

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetIndex ( string  name  )  const [inline]

Returns the index of the first element of the aggregated vector named name.

Parameters:
[in] name name of the aggregated vector.
Returns:
The index of the first element of the aggregated vector.

Definition at line 410 of file VectorCollection.cxx.

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetLength (  )  const [inline]

Returns the total number of elements.

Returns:
The total length of the vector.

Reimplemented from Seldon::Vector_Base< T, Allocator >.

Definition at line 345 of file VectorCollection.cxx.

template<class T , class Allocator >
const Vector< int, VectFull, MallocAlloc< int > > & Seldon::Vector< T, Collection, Allocator >::GetLengthSum (  )  const [inline]

Returns the cumulative sum of the lengths of the underlying vectors.

Returns:
The cumulative sum of the lengths of the underlying vectors.

Definition at line 380 of file VectorCollection.cxx.

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetM (  )  const [inline]

Returns the total number of elements.

Returns:
The total length of the vector.

Reimplemented from Seldon::Vector_Base< T, Allocator >.

Definition at line 334 of file VectorCollection.cxx.

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetNvector (  )  const [inline]

Returns the number of aggregated vectors.

Returns:
The total number of aggregated vectors.

Definition at line 356 of file VectorCollection.cxx.

template<class T , class Allocator >
int Seldon::Vector_Base< T, Allocator >::GetSize (  )  const [inherited]

Returns the number of elements stored.

Returns:
The length of the vector stored.

Definition at line 144 of file Vector.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( int  i  )  [inline]

Returns one of the aggregated vectors.

Parameters:
[in] i the index of the vector to be returned.
Returns:
The i th aggregated vector.

Definition at line 452 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( int  i  )  const [inline]

Returns one of the aggregated vectors.

Parameters:
[in] i the index of the vector to be returned.
Returns:
The i th aggregated vector.

Definition at line 466 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( string  name  )  [inline]

Returns one of the aggregated vectors.

Parameters:
[in] name the name of the vector to be returned.
Returns:
The aggregated vector named name.

Definition at line 479 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( string  name  )  const [inline]

Returns one of the aggregated vectors.

Parameters:
[in] name the name of the vector to be returned.
Returns:
The aggregated vector named name.

Definition at line 498 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::collection_reference Seldon::Vector< T, Collection, Allocator >::GetVector (  )  [inline]

Returns the list of vectors.

Returns:
The list of the aggregated vectors.

Definition at line 427 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_collection_reference Seldon::Vector< T, Collection, Allocator >::GetVector (  )  const [inline]

Returns the list of vectors.

Returns:
The list of the aggregated vectors.

Definition at line 439 of file VectorCollection.cxx.

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetVectorIndex ( string  name  )  const [inline]

Returns the vector index of the aggregated vector named name.

Parameters:
[in] name name of the aggregated vector.
Returns:
The vector index of the aggregated vector.

Definition at line 393 of file VectorCollection.cxx.

template<class T , class Allocator >
const Vector< int, VectFull, MallocAlloc< int > > & Seldon::Vector< T, Collection, Allocator >::GetVectorLength (  )  const [inline]

Returns the length vector of the underlying vectors.

Returns:
The lengths of the underlying vectors.

Definition at line 368 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_reference Seldon::Vector< T, Collection, Allocator >::operator() ( int  i  )  const [inline]

Access operator.

Parameters:
[in] i index.
Returns:
The value of the vector at 'i'.

Definition at line 545 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator >::reference Seldon::Vector< T, Collection, Allocator >::operator() ( int  i  )  [inline]

Access operator.

Parameters:
[in] i index.
Returns:
The value of the vector at 'i'.

Definition at line 521 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 >
Vector< T, Collection, Allocator > & Seldon::Vector< T, Collection, Allocator >::operator*= ( const T0 &  alpha  )  [inline]

Multiplies a vector collection by a scalar.

Parameters:
[in] alpha scalar.

Definition at line 627 of file VectorCollection.cxx.

template<class T , class Allocator >
Vector< T, Collection, Allocator > & Seldon::Vector< T, Collection, Allocator >::operator= ( const Vector< T, Collection, Allocator > &  X  )  [inline]

Duplicates a vector collection (assignment operator).

Parameters:
[in] X vector collection to be copied.
Note:
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 571 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Read ( string  FileName,
Vector< int, VectFull, MallocAlloc< int > > &  length 
)

Sets the vector from a file.

Sets the vector according to a binary file that stores the length of the vector (integer) and all elements.

Parameters:
FileName file name.

Definition at line 798 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Read ( istream &  FileStream,
Vector< int, VectFull, MallocAlloc< int > > &  length 
)

Sets the vector from a file stream.

Sets the vector according to a binary file stream that stores the length of the vector (integer) and all elements.

Parameters:
FileStream file stream.

Definition at line 824 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Reallocate ( int  i  )  [inline]

Reallocates the vector collection.

This method first clears the collection. Then it allocates a new vector of size i, and puts this vector in the collection. On exit, the collection is only composed of this vector of size i.

Parameters:
[in] i new size.

Definition at line 126 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::SetData ( const Vector< T, Collection, Allocator > &  X  ) 

Changes the length of the collection and sets its data array.

Parameters:
[in] X collection with the vectors to which the current collection will point on exit.

Definition at line 303 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::SetName ( int  i,
string  name 
)

Sets the name of a given underlying vector.

Parameters:
[in] i a given index.
[in] name name of the underlying vector.

Definition at line 274 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( int  i,
const Vector< T0, Storage0, Allocator0 > &  vector,
string  name 
)

Sets a vector in the list of vectors.

Parameters:
[in] i index of the vector to be set.
[in] vector vector to which the i th vector is set.
[in] name new name of the i th vector.

Definition at line 239 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( int  i,
const Vector< T0, Storage0, Allocator0 > &  vector 
)

Sets a vector in the list of vectors.

Parameters:
[in] i index of the vector to be set.
[in] vector new value of the vector.

Definition at line 215 of file VectorCollection.cxx.

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( string  name,
const Vector< T0, Storage0, Allocator0 > &  vector 
)

Sets a vector in the list of vectors.

Parameters:
[in] name name of the vector to be set.
[in] vector new value of the vector.

Definition at line 255 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Write ( ostream &  FileStream,
bool  with_size = true 
) const

Writes the vector in a file stream.

The length of the vector (integer) and all elements of the vector are stored in binary format.

Parameters:
FileStream file stream.
with_size if set to 'false', the length of the vector is not saved.

Definition at line 706 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Write ( string  FileName,
bool  with_size = true 
) const

Writes the inner vectors in a file.

The length of the vector (integer) and all elements of the vector are stored in binary format.

Parameters:
FileName file name.
with_size if set to 'false', the length of the vector is not saved.

Definition at line 679 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::WriteText ( ostream &  FileStream  )  const

Writes the vector in a file stream.

All elements of the vector are stored in text format. The length is not stored.

Parameters:
FileStream file stream.

Definition at line 768 of file VectorCollection.cxx.

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::WriteText ( string  FileName  )  const

Writes the vector in a file.

All elements of the vector are stored in text format. The length is not stored.

Parameters:
FileName file name.

Definition at line 740 of file VectorCollection.cxx.


The documentation for this class was generated from the following files: