Represents a sparse vector. More...
#include <sparse_vector.hh>
Classes | |
class | element |
Element of sparse vector. More... | |
Public Types | |
typedef T | value_t |
type of vector entries | |
typedef size_t | size_type |
usual definition of size_type | |
typedef size_type | key_t |
type of vector index pair | |
typedef map_t::const_iterator | const_iterator |
Stl-compatible constant iterator over vector elements. | |
Public Member Functions | |
SparseVector (const value_t &def) | |
Construct with default value. | |
element | operator[] (size_type i) |
Access to vector element. | |
const value_t & | operator[] (size_type i) const |
Read-only access to vector element of const vector. | |
void | set (size_type i, const value_t &val) |
Write access to vector entry. | |
void | reset (size_type i) |
Set vector entry to default value. | |
size_type | size () const |
Size of sparse vector. | |
bool | empty () const |
Check for emptiness. | |
void | clear () |
Clear the vector. | |
const_iterator | begin () const |
Begin const iterator over vector entries. | |
const_iterator | end () const |
End const iterator over vector entries. | |
Protected Types | |
typedef unordered_map< key_t, value_t >::type | map_t |
map type | |
Protected Attributes | |
map_t | the_map_ |
internal representation of sparse vector | |
value_t | def_ |
default value of vector entries |
Represents a sparse vector.
Sparse vector of entries val_t implements the vector by a hash map. The class is designed to be largely exchangable with non-sparse vectors.
typedef map_t::const_iterator LocARNA::SparseVector< T >::const_iterator |
Stl-compatible constant iterator over vector elements.
Behaves like a const iterator of the hash map.
LocARNA::SparseVector< T >::SparseVector | ( | const value_t & | def | ) | [inline, explicit] |
Construct with default value.
def | default value of entries |
const_iterator LocARNA::SparseVector< T >::begin | ( | ) | const [inline] |
Begin const iterator over vector entries.
bool LocARNA::SparseVector< T >::empty | ( | ) | const [inline] |
Check for emptiness.
const_iterator LocARNA::SparseVector< T >::end | ( | ) | const [inline] |
End const iterator over vector entries.
element LocARNA::SparseVector< T >::operator[] | ( | size_type | i | ) | [inline] |
Access to vector element.
i | index first dimension |
const value_t& LocARNA::SparseVector< T >::operator[] | ( | size_type | i | ) | const [inline] |
Read-only access to vector element of const vector.
i | index first dimension |
void LocARNA::SparseVector< T >::reset | ( | size_type | i | ) | [inline] |
Set vector entry to default value.
i | index first dimension |
void LocARNA::SparseVector< T >::set | ( | size_type | i, |
const value_t & | val | ||
) | [inline] |
Write access to vector entry.
i | index first dimension |
val | value to be written to entry i |
size_type LocARNA::SparseVector< T >::size | ( | ) | const [inline] |
Size of sparse vector.