LocARNA-2.0.0
|
Base class template for sparse vector and matrix. More...
#include <sparse_vector_base.hh>
Classes | |
class | element_proxy |
Proxy for element of sparse vector. More... | |
Public Types | |
using | derived_type = Derived |
using | value_type = ValueType |
type of vector entries | |
using | key_type = KeyType |
type of vector index | |
using | map_type = std::unordered_map< KeyType, ValueType > |
using | size_type = size_t |
usual definition of size_type | |
using | const_iterator = typename map_type::const_iterator |
Stl-compatible constant iterator over vector elements. More... | |
using | iterator = typename map_type::iterator |
Public Member Functions | |
SparseVectorBase (const value_type def) | |
element_proxy | operator[] (const key_type &i) |
Access to vector element. More... | |
const value_type & | operator[] (const key_type &i) const |
Read-only access to vector element of const vector. More... | |
void | set (const key_type &i, const value_type &val) |
Write access to vector entry. More... | |
value_type & | ref (const key_type &i) |
Write access to element. More... | |
void | reset (const key_type &i) |
Set vector entry to default value. More... | |
size_type | size () const |
Size of sparse vector. More... | |
bool | empty () const |
Check for emptiness. More... | |
void | clear () |
Clear the vector. | |
const_iterator | begin () const |
Begin const iterator over vector entries. More... | |
const_iterator | end () const |
End const iterator over vector entries. More... | |
const value_type & | def () const |
Default value. More... | |
Protected Attributes | |
value_type | def_ |
default value of vector entries | |
map_type | the_map_ |
internal representation of sparse vector | |
Base class template for sparse vector and matrix.
the first template argument is the derived sparse vector or matrix class (curiously recurring template pattern)
using LocARNA::SparseVectorBase< Derived, ValueType, KeyType >::const_iterator = typename map_type::const_iterator |
Stl-compatible constant iterator over vector elements.
Behaves like a const iterator of the hash map.
|
inline |
Begin const iterator over vector entries.
|
inline |
Default value.
|
inline |
Check for emptiness.
|
inline |
End const iterator over vector entries.
|
inline |
Access to vector element.
i | index first dimension |
|
inline |
Read-only access to vector element of const vector.
i | index first dimension |
|
inline |
Write access to element.
i | index |
|
inline |
Set vector entry to default value.
i | index first dimension |
|
inline |
Write access to vector entry.
i | index first dimension |
val | value to be written to entry i |
|
inline |
Size of sparse vector.