aimstil
5.0.5
|
A class that mimic the behavior of std::vector but with a storage policy focused on sparse data. More...
#include <til/sparse_vector.h>
Classes | |
class | const_iterator |
class | iterator |
class | OutOfRange |
class | sparse_const_iterator |
class | sparse_iterator |
Public Types | |
typedef sparse_vector< T > | Self |
typedef std::map< std::size_t, T > | Map |
typedef Map::mapped_type | value_type |
typedef T | const_reference |
typedef ValueProxy | reference |
typedef const T * | const_pointer |
Public Member Functions | |
sparse_vector () | |
Create a null vector of size 0. More... | |
sparse_vector (std::size_t d) | |
Create a null vector of length d. More... | |
ValueProxy | operator[] (std::size_t i) |
Read-write access to i-th element. More... | |
T | operator[] (std::size_t i) const |
Get value of i-th element. More... | |
T | get (std::size_t i) const |
Get i-th value. More... | |
void | set (std::size_t i, const T &value) |
Set n-th value. More... | |
Map & | getMap () |
Returns the internal data. More... | |
Map const & | getMap () const |
BaselinePolicy | baselinePolicy () const |
BaselinePolicy & | baselinePolicy () |
std::size_t | size () const |
Alike STL container's "size". More... | |
void | clear () |
Alike STL container's "clear". More... | |
bool | empty () const |
Alike STL container's "empty". More... | |
void | erase (const sparse_iterator &i) |
Alike STL container's "erase". More... | |
bool | is_null () const |
sparse_iterator | sparse_begin () |
sparse_iterator | sparse_end () |
sparse_const_iterator | sparse_begin () const |
sparse_const_iterator | sparse_end () const |
const_iterator | begin () const |
const_iterator | end () const |
iterator | begin () |
iterator | end () |
void | operator+= (const sparse_vector< T > &a) |
void | operator-= (const sparse_vector< T > &a) |
void | operator*= (const sparse_vector< T > &a) |
void | operator/= (const sparse_vector< T > &a) |
void | operator+= (const T &value) |
void | operator-= (const T &value) |
void | operator*= (const T &value) |
A class that mimic the behavior of std::vector but with a storage policy focused on sparse data.
Basically, a sparse vector has a default value, and stores only values that are not equal to this default value. Conceptually just a std::map with a default value, if you like. But then, everything starts being more complicated because of the apparent similarity with std::vector... Note that this is a container – if you are looking for a more mathematical object, have a look at SparseVector, the sparse counterpart of Vector.
Definition at line 134 of file sparse_vector.h.
typedef const T* til::sparse_vector< T, BaselinePolicy >::const_pointer |
Definition at line 161 of file sparse_vector.h.
typedef T til::sparse_vector< T, BaselinePolicy >::const_reference |
Definition at line 159 of file sparse_vector.h.
typedef std::map<std::size_t, T> til::sparse_vector< T, BaselinePolicy >::Map |
Definition at line 156 of file sparse_vector.h.
typedef ValueProxy til::sparse_vector< T, BaselinePolicy >::reference |
Definition at line 160 of file sparse_vector.h.
typedef sparse_vector<T> til::sparse_vector< T, BaselinePolicy >::Self |
Definition at line 151 of file sparse_vector.h.
typedef Map::mapped_type til::sparse_vector< T, BaselinePolicy >::value_type |
Definition at line 158 of file sparse_vector.h.
|
inline |
Create a null vector of size 0.
Definition at line 166 of file sparse_vector.h.
|
inline |
Create a null vector of length d.
Definition at line 174 of file sparse_vector.h.
|
inline |
Definition at line 321 of file sparse_vector.h.
Referenced by til::fill().
|
inline |
Definition at line 322 of file sparse_vector.h.
|
inline |
Definition at line 389 of file sparse_vector.h.
|
inline |
Definition at line 391 of file sparse_vector.h.
|
inline |
Alike STL container's "clear".
Definition at line 332 of file sparse_vector.h.
|
inline |
Alike STL container's "empty".
Definition at line 339 of file sparse_vector.h.
|
inline |
Definition at line 390 of file sparse_vector.h.
|
inline |
Definition at line 392 of file sparse_vector.h.
|
inline |
Alike STL container's "erase".
Definition at line 342 of file sparse_vector.h.
|
inline |
Get i-th value.
Definition at line 224 of file sparse_vector.h.
|
inline |
Returns the internal data.
Definition at line 315 of file sparse_vector.h.
Referenced by til::fill(), til::is_nan(), til::sparse_vector< T >::operator*=(), til::sparse_vector< T >::operator+=(), til::sparse_vector< T >::operator-=(), and til::sparse_vector< T >::operator/=().
|
inline |
Definition at line 316 of file sparse_vector.h.
|
inline |
Definition at line 345 of file sparse_vector.h.
|
inline |
Definition at line 408 of file sparse_vector.h.
|
inline |
Definition at line 417 of file sparse_vector.h.
|
inline |
Definition at line 404 of file sparse_vector.h.
|
inline |
Definition at line 413 of file sparse_vector.h.
|
inline |
Definition at line 406 of file sparse_vector.h.
|
inline |
Definition at line 415 of file sparse_vector.h.
|
inline |
Definition at line 410 of file sparse_vector.h.
|
inline |
Read-write access to i-th element.
NB: never use this operator if you are using map iterators at the same time. This is because operator[] may remove elements from the map and invalidate an existing iterator pointing to the removed element.
Definition at line 187 of file sparse_vector.h.
|
inline |
Get value of i-th element.
Definition at line 205 of file sparse_vector.h.
|
inline |
Set n-th value.
Definition at line 263 of file sparse_vector.h.
|
inline |
Alike STL container's "size".
Return the size of the vector (this is not the number of non-default elements, but the real size of the underlying vector).
Definition at line 329 of file sparse_vector.h.
|
inline |
Definition at line 384 of file sparse_vector.h.
Referenced by til::operator<<().
|
inline |
Definition at line 386 of file sparse_vector.h.
|
inline |
Definition at line 385 of file sparse_vector.h.
|
inline |
Definition at line 387 of file sparse_vector.h.