Structure for distributed vectors. More...
#include <VectorCollection.hxx>
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 vector_type & | vector_reference |
typedef Vector< vector_type, VectFull, NewAlloc< vector_type > > | collection_type |
typedef collection_type & | collection_reference |
typedef Collection | storage |
typedef Allocator | allocator |
Public Member Functions | |
Vector () | |
Methods. More... | |
Vector (int i) | |
Main constructor. More... | |
Vector (const Vector< T, Collection, Allocator > &A) | |
Copy constructor. More... | |
~Vector () | |
Destructor. More... | |
void | Clear () |
Clears the vector collection. More... | |
void | Reallocate (int i) |
Reallocates the vector collection. More... | |
void | Deallocate () |
Clears the vector collection. More... | |
template<class T0 , class Storage0 , class Allocator0 > | |
void | AddVector (const Vector< T0, Storage0, Allocator0 > &vector) |
Adds a vector to the list of vectors. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | SetName (int i, string name) |
Sets the name of a given underlying vector. More... | |
void | SetData (const Vector< T, Collection, Allocator > &X) |
Changes the length of the collection and sets its data array. More... | |
void | Nullify () |
Nullifies vectors of the collection without memory deallocation. | |
int | GetM () const |
Returns the total number of elements. More... | |
int | GetLength () const |
Returns the total number of elements. More... | |
int | GetNvector () const |
Returns the number of aggregated vectors. More... | |
const Vector< int, VectFull, MallocAlloc< int > > & | GetVectorLength () const |
Returns the length vector of the underlying vectors. More... | |
const Vector< int, VectFull, MallocAlloc< int > > & | GetLengthSum () const |
Returns the cumulative sum of the lengths of the underlying vectors. More... | |
int | GetVectorIndex (string name) const |
Returns the vector index of the aggregated vector named name. More... | |
int | GetIndex (string name) const |
Returns the index of the first element of the aggregated vector named name. More... | |
collection_reference | GetVector () |
Returns the list of vectors. More... | |
const_collection_reference | GetVector () const |
vector_reference | GetVector (int i) |
Returns one of the aggregated vectors. More... | |
const_vector_reference | GetVector (int i) const |
Returns one of the aggregated vectors. More... | |
vector_reference | GetVector (string name) |
Returns one of the aggregated vectors. More... | |
const_vector_reference | GetVector (string name) const |
Returns one of the aggregated vectors. More... | |
const_reference | operator() (int i) const |
Access operator. More... | |
reference | operator() (int i) |
Access operator. More... | |
Vector< T, Collection, Allocator > & | operator= (const Vector< T, Collection, Allocator > &X) |
Duplicates a vector collection (assignment operator). More... | |
void | Copy (const Vector< T, Collection, Allocator > &X) |
Duplicates a vector collection. More... | |
template<class T0 , class Allocator0 > | |
void | Copy (const Vector< T0, VectFull, Allocator0 > &X) |
Copies the values of a full vector into the current vector. More... | |
template<class T0 > | |
Vector< T, Collection, Allocator > & | operator*= (const T0 &X) |
Multiplies a vector collection by a scalar. More... | |
template<class T0 > | |
void | Fill (const T0 &x) |
Fills the collection with a given value. More... | |
void | Print () const |
Displays the vector. | |
void | Write (string FileName, bool with_size=true) const |
Writes the inner vectors in a file. More... | |
void | Write (ostream &FileStream, bool with_size=true) const |
Writes the vector in a file stream. More... | |
void | WriteText (string FileName) const |
Writes the vector in a file. More... | |
void | WriteText (ostream &FileStream) const |
Writes the vector in a file stream. More... | |
void | Read (string FileName) |
Sets the vector from a file. More... | |
void | Read (string FileName, Vector< int, VectFull, MallocAlloc< int > > &length_) |
Sets the vector from a file. More... | |
void | Read (istream &FileStream, Vector< int, VectFull, MallocAlloc< int > > &length_) |
Sets the vector from a file stream. More... | |
size_t | GetSize () const |
Returns the number of elements stored. More... | |
size_t | GetMemorySize () const |
Returns the memory used by the object in bytes. More... | |
pointer | GetData () const |
Returns a pointer to data_ (stored data). More... | |
const_pointer | GetDataConst () const |
Returns a const pointer to data_ (stored data). More... | |
void * | GetDataVoid () const |
Returns a pointer of type "void*" to the data array (data_). More... | |
const void * | GetDataConstVoid () const |
Returns a pointer of type "const void*" to the data array (data_). More... | |
Public Attributes | |
const typedef vector_type * | const_vector_pointer |
const typedef vector_type & | const_vector_reference |
const typedef collection_type | const_collection_type |
const typedef collection_type & | const_collection_reference |
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. | |
size_t | m_ |
pointer | data_ |
Structure for distributed vectors.
Definition at line 38 of file VectorCollection.hxx.
|
inlineexplicit |
Methods.
Default constructor.
Nothing is allocated. The vector length is set to zero.
Definition at line 46 of file VectorCollectionInline.cxx.
|
inlineexplicit |
Main constructor.
Builds a vector collection of a given size.
[in] | i | length of the vector. |
Definition at line 58 of file VectorCollectionInline.cxx.
|
inline |
Copy constructor.
Builds a copy of a vector collection.
[in] | V | vector collection to be copied. |
Definition at line 74 of file VectorCollectionInline.cxx.
Seldon::Vector< T, Collection, Allocator >::~Vector |
Destructor.
The inner vectors are nullified so that their memory blocks should not be deallocated.
Definition at line 46 of file VectorCollection.cxx.
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.
[in] | vector | vector to be appended. |
Definition at line 305 of file VectorCollection.cxx.
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.
[in] | vector | vector to be appended. |
[in] | name | name of the vector to be appended. |
Definition at line 336 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Clear |
Clears the vector collection.
The inner vectors are nullified so that their memory blocks should not be deallocated.
Definition at line 60 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Copy | ( | const Vector< T, Collection, Allocator > & | X | ) |
Duplicates a vector collection.
[in] | X | vector collection to be copied. |
Definition at line 264 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Copy | ( | const Vector< T0, VectFull, Allocator0 > & | X | ) |
Copies the values of a full vector into the current vector.
[in] | X | full vector to be copied. |
Definition at line 283 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Deallocate |
Clears the vector collection.
The inner vectors are cleared and the memory blocks are deallocated.
Definition at line 96 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Fill | ( | const T0 & | x | ) |
Fills the collection with a given value.
x | value to fill the collection with. |
Definition at line 473 of file VectorCollection.cxx.
|
inlineinherited |
Returns a pointer to data_ (stored data).
Definition at line 177 of file VectorInline.cxx.
|
inlineinherited |
Returns a const pointer to data_ (stored data).
Definition at line 189 of file VectorInline.cxx.
|
inlineinherited |
Returns a pointer of type "const void*" to the data array (data_).
Definition at line 212 of file VectorInline.cxx.
|
inlineinherited |
Returns a pointer of type "void*" to the data array (data_).
Definition at line 201 of file VectorInline.cxx.
int Seldon::Vector< T, Collection, Allocator >::GetIndex | ( | string | name | ) | const |
Returns the index of the first element of the aggregated vector named name.
[in] | name | name of the aggregated vector. |
Definition at line 139 of file VectorCollection.cxx.
|
inline |
Returns the total number of elements.
Definition at line 102 of file VectorCollectionInline.cxx.
|
inline |
Returns the cumulative sum of the lengths of the underlying vectors.
Definition at line 137 of file VectorCollectionInline.cxx.
|
inline |
Returns the total number of elements.
Definition at line 91 of file VectorCollectionInline.cxx.
|
inlineinherited |
Returns the memory used by the object in bytes.
In this method, the type T is assumed to be "static" such that sizeof(T) provides the correct size
Definition at line 165 of file VectorInline.cxx.
|
inline |
Returns the number of aggregated vectors.
Definition at line 113 of file VectorCollectionInline.cxx.
|
inlineinherited |
Returns the number of elements stored.
Definition at line 153 of file VectorInline.cxx.
|
inline |
Returns the list of vectors.
Definition at line 149 of file VectorCollectionInline.cxx.
|
inline |
Returns one of the aggregated vectors.
[in] | i | the index of the vector to be returned. |
Definition at line 174 of file VectorCollectionInline.cxx.
|
inline |
Returns one of the aggregated vectors.
[in] | i | the index of the vector to be returned. |
Definition at line 188 of file VectorCollectionInline.cxx.
Vector< T, Collection, Allocator >::vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector | ( | string | name | ) |
Returns one of the aggregated vectors.
[in] | name | the name of the vector to be returned. |
Definition at line 176 of file VectorCollection.cxx.
Vector< T, Collection, Allocator >::const_vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector | ( | string | name | ) | const |
Returns one of the aggregated vectors.
[in] | name | the name of the vector to be returned. |
Definition at line 158 of file VectorCollection.cxx.
int Seldon::Vector< T, Collection, Allocator >::GetVectorIndex | ( | string | name | ) | const |
Returns the vector index of the aggregated vector named name.
[in] | name | name of the aggregated vector. |
Definition at line 122 of file VectorCollection.cxx.
|
inline |
Returns the length vector of the underlying vectors.
Definition at line 125 of file VectorCollectionInline.cxx.
Vector< T, Collection, Allocator >::reference Seldon::Vector< T, Collection, Allocator >::operator() | ( | int | i | ) |
Access operator.
[in] | i | index. |
Definition at line 199 of file VectorCollection.cxx.
Vector< T, Collection, Allocator >::const_reference Seldon::Vector< T, Collection, Allocator >::operator() | ( | int | i | ) | const |
Access operator.
[in] | i | index. |
Definition at line 223 of file VectorCollection.cxx.
|
inline |
Multiplies a vector collection by a scalar.
[in] | alpha | scalar. |
Definition at line 201 of file VectorCollectionInline.cxx.
Vector< T, Collection, Allocator > & Seldon::Vector< T, Collection, Allocator >::operator= | ( | const Vector< T, Collection, Allocator > & | X | ) |
Duplicates a vector collection (assignment operator).
[in] | X | vector collection to be copied. |
Definition at line 249 of file VectorCollection.cxx.
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.
FileStream | file stream. |
Definition at line 678 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Read | ( | string | FileName | ) |
Sets the vector from a file.
Sets the vector according to a binary file that stores the length of the collection (number of inner vectors), followed by the inner vectors (i.e., an integer followed by data).
FileName | file name. |
Definition at line 623 of file VectorCollection.cxx.
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.
FileName | file name. |
Definition at line 652 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::Reallocate | ( | int | i | ) |
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.
[in] | i | new size. |
Definition at line 81 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::SetData | ( | const Vector< T, Collection, Allocator > & | X | ) |
Changes the length of the collection and sets its data array.
[in] | X | collection with the vectors to which the current collection will point on exit. |
Definition at line 441 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::SetName | ( | int | i, |
string | name | ||
) |
Sets the name of a given underlying vector.
[in] | i | a given index. |
[in] | name | name of the underlying vector. |
Definition at line 412 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::SetVector | ( | int | i, |
const Vector< T0, Storage0, Allocator0 > & | vector | ||
) |
Sets a vector in the list of vectors.
[in] | i | index of the vector to be set. |
[in] | vector | new value of the vector. |
Definition at line 353 of file VectorCollection.cxx.
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.
[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 377 of file VectorCollection.cxx.
void Seldon::Vector< T, Collection, Allocator >::SetVector | ( | string | name, |
const Vector< T0, Storage0, Allocator0 > & | vector | ||
) |
Sets a vector in the list of vectors.
[in] | name | name of the vector to be set. |
[in] | vector | new value of the vector. |
Definition at line 393 of file VectorCollection.cxx.
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.
FileStream | file stream. |
with_size | if set to 'false', the length of the vector is not saved. |
Definition at line 532 of file VectorCollection.cxx.
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.
FileName | file name. |
with_size | if set to 'false', the length of the vector is not saved. |
Definition at line 505 of file VectorCollection.cxx.
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.
FileStream | file stream. |
Definition at line 594 of file VectorCollection.cxx.
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.
FileName | file name. |
Definition at line 566 of file VectorCollection.cxx.