![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Sparse vector that stores only non-default entries in an associative key-to-value container. More...
#include <Vector.hpp>
Inheritance diagram for CDPL::Math::SparseVector< T, A >:Public Types | |
| typedef T | ValueType |
| typedef std::size_t | SizeType |
| The unsigned size type. More... | |
| typedef std::ptrdiff_t | DifferenceType |
| The signed difference type. More... | |
| typedef A::key_type | KeyType |
| The key type used by the underlying associative container. More... | |
| typedef const T & | ConstReference |
| Constant reference type to a stored element value. More... | |
| typedef SparseContainerElement< SelfType, KeyType > | Reference |
| Mutable reference type (a proxy object that inserts on assignment to a previously-absent key). More... | |
| typedef A | ArrayType |
| The underlying associative container type. More... | |
| typedef T * | Pointer |
| Pointer type for raw access to stored entries. More... | |
| typedef const T * | ConstPointer |
| Constant pointer type for raw access to stored entries. More... | |
| typedef VectorReference< SelfType > | ClosureType |
| Closure type used when this vector appears inside another expression. More... | |
| typedef const VectorReference< const SelfType > | ConstClosureType |
| Constant closure type used when this vector appears inside another expression. More... | |
| typedef SelfType | VectorTemporaryType |
| Concrete temporary vector type used by expression-template machinery. More... | |
| typedef std::shared_ptr< SelfType > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseVector instances. More... | |
| typedef std::initializer_list< T > | InitializerListType |
| The initializer-list type accepted by constructors and assignment. More... | |
Public Types inherited from CDPL::Math::VectorContainer< SparseVector< T, std::unordered_map< std::size_t, T > > > | |
| typedef SparseVector< T, std::unordered_map< std::size_t, T > > | ContainerType |
| The derived vector container type. More... | |
Public Types inherited from CDPL::Math::VectorExpression< E > | |
| typedef E | ExpressionType |
| The derived vector expression type. More... | |
Public Types inherited from CDPL::Math::Expression< E > | |
| typedef E | ExpressionType |
| The derived expression type (made available to expression-template machinery). More... | |
Public Member Functions | |
| SparseVector () | |
| Constructs an empty sparse vector (size zero, no stored entries). More... | |
| SparseVector (SizeType n) | |
| Constructs a sparse vector of size n with no stored entries (every position reads as the default value). More... | |
| SparseVector (const SparseVector &v) | |
| Constructs a copy of the sparse vector v. More... | |
| SparseVector (SparseVector &&v) | |
| Move-constructs from v (v is left in a valid empty state). More... | |
| SparseVector (InitializerListType l) | |
| Constructs a sparse vector with the contents of the initializer list l. More... | |
| template<typename E > | |
| SparseVector (const VectorExpression< E > &e) | |
| Constructs a sparse vector from the vector expression e. More... | |
| Reference | operator[] (SizeType i) |
| Returns a mutable proxy reference to the element at index i (alias for operator()). More... | |
| ConstReference | operator[] (SizeType i) const |
Returns a const reference to the element at index i (alias for operator()). More... | |
| Reference | operator() (SizeType i) |
| Returns a mutable proxy reference to the element at index i. More... | |
| ConstReference | operator() (SizeType i) const |
Returns a const reference to the element at index i. More... | |
| SizeType | getNumElements () const |
| Returns the number of explicitly stored (non-default) entries. More... | |
| bool | isEmpty () const |
| Tells whether the vector's logical size is zero. More... | |
| SizeType | getSize () const |
| Returns the logical element count. More... | |
| SizeType | getMaxSize () const |
| Returns the maximum number of stored entries the underlying associative container can hold. More... | |
| ArrayType & | getData () |
| Returns a mutable reference to the underlying associative container of stored entries. More... | |
| const ArrayType & | getData () const |
Returns a const reference to the underlying associative container of stored entries. More... | |
| SparseVector & | operator= (const SparseVector &v) |
| Copy-assigns the contents of v to this sparse vector. More... | |
| SparseVector & | operator= (SparseVector &&v) |
| Move-assigns the contents of v to this sparse vector. More... | |
| SparseVector & | operator= (InitializerListType l) |
| Assigns the contents of the initializer list l to this sparse vector. More... | |
| template<typename C > | |
| SparseVector & | operator= (const VectorContainer< C > &c) |
| Assigns the contents of the vector container c to this sparse vector (no alias check needed). More... | |
| template<typename E > | |
| SparseVector & | operator= (const VectorExpression< E > &e) |
| Assigns the vector expression e to this sparse vector (via a temporary to handle aliasing). More... | |
| template<typename C > | |
| SparseVector & | operator+= (const VectorContainer< C > &c) |
| Adds the contents of the vector container c element-wise to this sparse vector (no alias check needed). More... | |
| SparseVector & | operator+= (InitializerListType l) |
| Adds the contents of the initializer list l element-wise to this sparse vector. More... | |
| template<typename E > | |
| SparseVector & | operator+= (const VectorExpression< E > &e) |
| Adds the vector expression e element-wise to this sparse vector (via a temporary to handle aliasing). More... | |
| template<typename C > | |
| SparseVector & | operator-= (const VectorContainer< C > &c) |
| Subtracts the contents of the vector container c element-wise from this sparse vector (no alias check needed). More... | |
| SparseVector & | operator-= (InitializerListType l) |
| Subtracts the contents of the initializer list l element-wise from this sparse vector. More... | |
| template<typename E > | |
| SparseVector & | operator-= (const VectorExpression< E > &e) |
| Subtracts the vector expression e element-wise from this sparse vector (via a temporary to handle aliasing). More... | |
| template<typename T1 > | |
| std::enable_if< IsScalar< T1 >::value, SparseVector >::type & | operator*= (const T1 &t) |
| Multiplies every stored entry by the scalar t. More... | |
| template<typename T1 > | |
| std::enable_if< IsScalar< T1 >::value, SparseVector >::type & | operator/= (const T1 &t) |
| Divides every stored entry by the scalar t. More... | |
| template<typename E > | |
| SparseVector & | assign (const VectorExpression< E > &e) |
| Resizes this vector to match e and assigns the elements of e without intermediate temporary. More... | |
| SparseVector & | assign (InitializerListType l) |
| Resizes this vector to match l and assigns the elements of l. More... | |
| template<typename E > | |
| SparseVector & | plusAssign (const VectorExpression< E > &e) |
| Adds the elements of the vector expression e to this vector without intermediate temporary. More... | |
| SparseVector & | plusAssign (InitializerListType l) |
| Adds the contents of the initializer list l element-wise to this vector without intermediate temporary. More... | |
| template<typename E > | |
| SparseVector & | minusAssign (const VectorExpression< E > &e) |
| Subtracts the elements of the vector expression e from this vector without intermediate temporary. More... | |
| SparseVector & | minusAssign (InitializerListType l) |
| Subtracts the contents of the initializer list l element-wise from this vector without intermediate temporary. More... | |
| void | swap (SparseVector &v) |
| Swaps the contents of this sparse vector with those of v. More... | |
| void | clear () |
| Removes all explicitly stored entries (the logical size remains unchanged). More... | |
| void | resize (SizeType n) |
| Resizes the logical element count to n, dropping any stored entries at indices beyond n. More... | |
Public Member Functions inherited from CDPL::Math::VectorContainer< SparseVector< T, std::unordered_map< std::size_t, T > > > | |
| const ContainerType & | operator() () const |
Returns a const reference to the derived vector container. More... | |
| ContainerType & | operator() () |
| Returns a reference to the derived vector container. More... | |
Public Member Functions inherited from CDPL::Math::VectorExpression< E > | |
| const ExpressionType & | operator() () const |
Returns a const reference to the derived vector expression. More... | |
| ExpressionType & | operator() () |
| Returns a reference to the derived vector expression. More... | |
Friends | |
| void | swap (SparseVector &v1, SparseVector &v2) |
| ADL-enabled free-function form of swap(). More... | |
Additional Inherited Members | |
Protected Member Functions inherited from CDPL::Math::VectorContainer< SparseVector< T, std::unordered_map< std::size_t, T > > > | |
| VectorContainer () | |
| ~VectorContainer () | |
Protected Member Functions inherited from CDPL::Math::VectorExpression< E > | |
| VectorExpression () | |
| ~VectorExpression () | |
Protected Member Functions inherited from CDPL::Math::Expression< E > | |
| Expression () | |
| ~Expression () | |
Sparse vector that stores only non-default entries in an associative key-to-value container.
| T | The scalar value type. |
| A | The underlying associative container type (default: std::unordered_map). |
| typedef T CDPL::Math::SparseVector< T, A >::ValueType |
| typedef std::size_t CDPL::Math::SparseVector< T, A >::SizeType |
The unsigned size type.
| typedef std::ptrdiff_t CDPL::Math::SparseVector< T, A >::DifferenceType |
The signed difference type.
| typedef A::key_type CDPL::Math::SparseVector< T, A >::KeyType |
The key type used by the underlying associative container.
| typedef const T& CDPL::Math::SparseVector< T, A >::ConstReference |
Constant reference type to a stored element value.
| typedef SparseContainerElement<SelfType, KeyType> CDPL::Math::SparseVector< T, A >::Reference |
Mutable reference type (a proxy object that inserts on assignment to a previously-absent key).
| typedef A CDPL::Math::SparseVector< T, A >::ArrayType |
The underlying associative container type.
| typedef T* CDPL::Math::SparseVector< T, A >::Pointer |
Pointer type for raw access to stored entries.
| typedef const T* CDPL::Math::SparseVector< T, A >::ConstPointer |
Constant pointer type for raw access to stored entries.
| typedef VectorReference<SelfType> CDPL::Math::SparseVector< T, A >::ClosureType |
Closure type used when this vector appears inside another expression.
| typedef const VectorReference<const SelfType> CDPL::Math::SparseVector< T, A >::ConstClosureType |
Constant closure type used when this vector appears inside another expression.
| typedef SelfType CDPL::Math::SparseVector< T, A >::VectorTemporaryType |
Concrete temporary vector type used by expression-template machinery.
| typedef std::shared_ptr<SelfType> CDPL::Math::SparseVector< T, A >::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SparseVector instances.
| typedef std::initializer_list<T> CDPL::Math::SparseVector< T, A >::InitializerListType |
The initializer-list type accepted by constructors and assignment.
|
inline |
Constructs an empty sparse vector (size zero, no stored entries).
|
inlineexplicit |
Constructs a sparse vector of size n with no stored entries (every position reads as the default value).
| n | The logical element count. |
|
inline |
Constructs a copy of the sparse vector v.
| v | The sparse vector to copy. |
|
inline |
Move-constructs from v (v is left in a valid empty state).
| v | The sparse vector to move from. |
|
inline |
Constructs a sparse vector with the contents of the initializer list l.
| l | The initializer list providing the initial elements. |
|
inline |
Constructs a sparse vector from the vector expression e.
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Returns a mutable proxy reference to the element at index i (alias for operator()).
| i | The zero-based element index. |
| Base::IndexError | if i is out of range. |
|
inline |
Returns a const reference to the element at index i (alias for operator()).
| i | The zero-based element index. |
const reference to the element (or to the zero element if no entry is stored at i). | Base::IndexError | if i is out of range. |
|
inline |
Returns a mutable proxy reference to the element at index i.
| i | The zero-based element index. |
| Base::IndexError | if i is out of range. |
|
inline |
Returns a const reference to the element at index i.
| i | The zero-based element index. |
const reference to the stored value, or to the zero element if no entry exists at i. | Base::IndexError | if i is out of range. |
|
inline |
Returns the number of explicitly stored (non-default) entries.
|
inline |
Tells whether the vector's logical size is zero.
true if the logical size is zero, and false otherwise.
|
inline |
Returns the logical element count.
|
inline |
Returns the maximum number of stored entries the underlying associative container can hold.
|
inline |
Returns a mutable reference to the underlying associative container of stored entries.
|
inline |
Returns a const reference to the underlying associative container of stored entries.
const reference to the storage container.
|
inline |
Copy-assigns the contents of v to this sparse vector.
| v | The source sparse vector. |
|
inline |
Move-assigns the contents of v to this sparse vector.
| v | The source sparse vector (left in a valid but unspecified state). |
|
inline |
Assigns the contents of the initializer list l to this sparse vector.
| l | The initializer list providing the new elements. |
|
inline |
Assigns the contents of the vector container c to this sparse vector (no alias check needed).
| C | The source vector container type. |
| c | The source vector container. |
|
inline |
Assigns the vector expression e to this sparse vector (via a temporary to handle aliasing).
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Adds the contents of the vector container c element-wise to this sparse vector (no alias check needed).
| C | The source vector container type. |
| c | The source vector container. |
|
inline |
Adds the contents of the initializer list l element-wise to this sparse vector.
| l | The initializer list providing the addends. |
|
inline |
Adds the vector expression e element-wise to this sparse vector (via a temporary to handle aliasing).
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Subtracts the contents of the vector container c element-wise from this sparse vector (no alias check needed).
| C | The source vector container type. |
| c | The source vector container. |
|
inline |
Subtracts the contents of the initializer list l element-wise from this sparse vector.
| l | The initializer list providing the subtrahends. |
|
inline |
Subtracts the vector expression e element-wise from this sparse vector (via a temporary to handle aliasing).
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Multiplies every stored entry by the scalar t.
| T1 | The scalar type. |
| t | The scalar multiplier. |
|
inline |
Divides every stored entry by the scalar t.
| T1 | The scalar type. |
| t | The scalar divisor. |
|
inline |
Resizes this vector to match e and assigns the elements of e without intermediate temporary.
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Resizes this vector to match l and assigns the elements of l.
| l | The initializer list providing the new elements. |
|
inline |
Adds the elements of the vector expression e to this vector without intermediate temporary.
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Adds the contents of the initializer list l element-wise to this vector without intermediate temporary.
| l | The initializer list providing the addends. |
|
inline |
Subtracts the elements of the vector expression e from this vector without intermediate temporary.
| E | The source vector expression type. |
| e | The source vector expression. |
|
inline |
Subtracts the contents of the initializer list l element-wise from this vector without intermediate temporary.
| l | The initializer list providing the subtrahends. |
|
inline |
Swaps the contents of this sparse vector with those of v.
| v | The sparse vector to swap with. |
|
inline |
Removes all explicitly stored entries (the logical size remains unchanged).
|
inline |
Resizes the logical element count to n, dropping any stored entries at indices beyond n.
| n | The new logical element count. |
|
friend |
ADL-enabled free-function form of swap().
| v1 | The first sparse vector. |
| v2 | The second sparse vector. |