LocARNA-2.0.0
Public Member Functions | List of all members
LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy Class Reference

Proxy for element of sparse vector. More...

#include <sparse_vector_base.hh>

Public Member Functions

 element_proxy (derived_type *v, key_type k)
 Construct as proxy for specified element in given sparse vector. More...
 
 operator value_type ()
 Access entry for which the class acts as proxy. More...
 
element_proxy operator+= (const value_type &x)
 Operator for in place addition. More...
 
element_proxyoperator= (const value_type &x)
 Assignment operator. More...
 

Detailed Description

template<typename Derived, typename ValueType, typename KeyType = size_t>
class LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy

Proxy for element of sparse vector.

Proxy for sparse vector entries. This is required for non-const access to vector elements in order to provide a very similar syntax for the sparse data structure and the corresponding non-sparse vector.

Constructor & Destructor Documentation

◆ element_proxy()

template<typename Derived , typename ValueType , typename KeyType = size_t>
LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy::element_proxy ( derived_type *  v,
key_type  k 
)
inline

Construct as proxy for specified element in given sparse vector.

Parameters
mpointer to sparse vector
kkey/index of entry in given sparse vector

Member Function Documentation

◆ operator value_type()

template<typename Derived , typename ValueType , typename KeyType = size_t>
LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy::operator value_type ( )
inline

Access entry for which the class acts as proxy.

Returns
value of vector entry.

If entry does not exist, return the default value

◆ operator+=()

template<typename Derived , typename ValueType , typename KeyType = size_t>
element_proxy LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy::operator+= ( const value_type x)
inline

Operator for in place addition.

Parameters
xvalue
Postcondition
x is added to vector entry for that the class is proxy
Returns
*this after adding x
Note
If entry does not exist, x is added to the default value

◆ operator=()

template<typename Derived , typename ValueType , typename KeyType = size_t>
element_proxy& LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::element_proxy::operator= ( const value_type x)
inline

Assignment operator.

Parameters
xvalue
Postcondition
x is assigned to vector entry for that the class is proxy
Returns
*this after assigning x
Note
If x equals the default value and the entry exists, it is erased

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