Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
SparseVector< Value > Class Template Reference

SparseVector implementation. The container will not actually store a specified type of element - the sparse element, e.g. zero (by default) More...

#include <OpenMS/DATASTRUCTURES/SparseVector.h>

Classes

class  SparseVectorConstIterator
 const_iterator for SparseVector More...
 
class  SparseVectorConstReverseIterator
 const_reverse_iterator for SparseVector More...
 
class  SparseVectorIterator
 random access iterator for SparseVector including the hop() function to jump to the next non-sparse element More...
 
class  SparseVectorReverseIterator
 random access reverse iterator for SparseVector including the hop() function to jump to the next non-sparse element More...
 
class  ValueProxy
 class ValueProxy allows the SparseVector to differentiate between writing and reading, so zeros can be ignored See "more effective c++" section 30 More...
 

Public Types

typedef SparseVectorConstIterator const_iterator
 
typedef SparseVectorConstReverseIterator const_reverse_iterator
 
typedef SparseVectorIterator iterator
 
typedef SparseVectorReverseIterator reverse_iterator
 
typedef std::map< size_t, Value >::difference_type difference_type
 
typedef std::map< size_t, Value >::size_type size_type
 
typedef std::map< size_t, Value >::allocator_type allocator_type
 
typedef Value value_type
 
typedef Value * pointer
 
typedef ValueProxyreference
 
typedef const ValueProxyconst_reference
 
typedef std::map< size_t, Value >::const_iterator map_const_iterator
 
typedef std::map< size_t, Value >::iterator map_iterator
 
typedef std::map< size_t, Value >::const_reverse_iterator reverse_map_const_iterator
 
typedef std::map< size_t, Value >::reverse_iterator reverse_map_iterator
 
typedef SparseVectorConstIterator ConstIterator
 
typedef SparseVectorConstReverseIterator ConstReverseIterator
 
typedef SparseVectorIterator Iterator
 
typedef SparseVectorReverseIterator ReverseIterator
 

Public Member Functions

void print () const
 
 SparseVector ()
 default constructor More...
 
 SparseVector (Value se)
 constructor with chosen sparse element More...
 
 SparseVector (size_type size, Value value, Value se=0)
 detailed constructor, use with filling element value is discouraged unless it is the same as sparse element se More...
 
 SparseVector (const SparseVector &source)
 copy constructor More...
 
SparseVectoroperator= (const SparseVector &source)
 assignment operator More...
 
 ~SparseVector ()
 destructor More...
 
bool operator== (const SparseVector &rhs) const
 equality operator More...
 
bool operator< (const SparseVector &rhs) const
 less than operator More...
 
size_type nonzero_size () const
 number of nonzero elements, i.e. the space actually used More...
 
size_type size () const
 size of the represented vector More...
 
bool empty () const
 true if the container is empty More...
 
void push_back (Value value)
 push_back (see stl vector docs) More...
 
Value at (size_type pos) const
 
const Value operator[] (size_type pos) const
 ValueProxy handles the conversion to int and ,the writing ( if != sparseElement ) More...
 
ValueProxy operator[] (size_type pos)
 ValueProxy handles the conversion and the writing ( if != sparseElement ) More...
 
void clear ()
 removes all elements More...
 
void resize (size_type newsize)
 resizes the vector to param newsize More...
 
void erase (SparseVectorIterator it)
 
void erase (SparseVectorIterator first, SparseVectorIterator last)
 
SparseVectorIterator getMinElement ()
 gets an Iterator to the element (including sparseElements) with the minimal value More...
 
iterator begin ()
 begin iterator More...
 
iterator end ()
 end iterator More...
 
reverse_iterator rbegin ()
 rbegin iterator More...
 
reverse_iterator rend ()
 rend iterator More...
 
const_iterator begin () const
 const begin iterator More...
 
const_iterator end () const
 const end iterator More...
 
const_reverse_iterator rbegin () const
 const begin reverse_iterator More...
 
const_reverse_iterator rend () const
 const end reverse_iterator More...
 

Protected Member Functions

void update_ (map_iterator it, Size amount_deleted)
 Updates position of it and all larger elements. More...
 

Protected Attributes

Value sparse_element_
 sparse element More...
 

Private Attributes

std::map< size_type, Value > values_
 underlying map More...
 
size_type size_
 size including sparse elements More...
 

Detailed Description

template<typename Value>
class OpenMS::SparseVector< Value >

SparseVector implementation. The container will not actually store a specified type of element - the sparse element, e.g. zero (by default)

SparseVector for allround usage, will work with Int, UInt, double, float. This should use less space than a normal vector (if more than half of the elements are sparse elements, since the underlying structure is a map) and functions can just ignore sparse elements (hop(),

See also
SparseVectorIterator) for faster look over the elements of the container

Member Typedef Documentation

◆ allocator_type

typedef std::map<size_t, Value>::allocator_type allocator_type

◆ const_iterator

◆ const_reference

typedef const ValueProxy& const_reference

◆ const_reverse_iterator

◆ ConstIterator

◆ ConstReverseIterator

◆ difference_type

typedef std::map<size_t, Value>::difference_type difference_type

◆ iterator

◆ Iterator

◆ map_const_iterator

typedef std::map<size_t, Value>::const_iterator map_const_iterator

◆ map_iterator

typedef std::map<size_t, Value>::iterator map_iterator

◆ pointer

typedef Value* pointer

◆ reference

◆ reverse_iterator

◆ reverse_map_const_iterator

typedef std::map<size_t, Value>::const_reverse_iterator reverse_map_const_iterator

◆ reverse_map_iterator

typedef std::map<size_t, Value>::reverse_iterator reverse_map_iterator

◆ ReverseIterator

◆ size_type

typedef std::map<size_t, Value>::size_type size_type

◆ value_type

typedef Value value_type

Constructor & Destructor Documentation

◆ SparseVector() [1/4]

SparseVector ( )
inline

default constructor

◆ SparseVector() [2/4]

SparseVector ( Value  se)
inline

constructor with chosen sparse element

◆ SparseVector() [3/4]

SparseVector ( size_type  size,
Value  value,
Value  se = 0 
)
inline

detailed constructor, use with filling element value is discouraged unless it is the same as sparse element se

◆ SparseVector() [4/4]

SparseVector ( const SparseVector< Value > &  source)
inline

copy constructor

◆ ~SparseVector()

~SparseVector ( )
inline

destructor

Member Function Documentation

◆ at()

Value at ( size_type  pos) const
inline

at (see stl vector docs)

Parameters
posindex at which the desired element stays
Exceptions
OutOfRangeis thrown if the index is greater or equal than the size of the vector

◆ begin() [1/2]

iterator begin ( )
inline

◆ begin() [2/2]

const_iterator begin ( ) const
inline

const begin iterator

◆ clear()

void clear ( )
inline

removes all elements

◆ empty()

bool empty ( ) const
inline

true if the container is empty

Referenced by BinnedSpectrum::getBins().

◆ end() [1/2]

iterator end ( )
inline

◆ end() [2/2]

const_iterator end ( ) const
inline

const end iterator

◆ erase() [1/2]

void erase ( SparseVectorIterator  it)
inline

erase indicated element(iterator) and immediately update indices in map

Parameters
itparameter which specifies the element which should be deleted
Exceptions
OutOfRangeis thrown if the iterator does not point to an element

◆ erase() [2/2]

void erase ( SparseVectorIterator  first,
SparseVectorIterator  last 
)
inline

erase indicated element(half open iterator-range) and immediately update indices in map

Parameters
firstiterator that points to the begin of the range which should be erased
lastiterator that points one position behind the last position which should be erased

◆ getMinElement()

SparseVectorIterator getMinElement ( )
inline

gets an Iterator to the element (including sparseElements) with the minimal value

◆ nonzero_size()

size_type nonzero_size ( ) const
inline

number of nonzero elements, i.e. the space actually used

Referenced by BinnedSpectrum::getFilledBinNumber().

◆ operator<()

bool operator< ( const SparseVector< Value > &  rhs) const
inline

less than operator

◆ operator=()

SparseVector& operator= ( const SparseVector< Value > &  source)
inline

assignment operator

◆ operator==()

bool operator== ( const SparseVector< Value > &  rhs) const
inline

equality operator

◆ operator[]() [1/2]

const Value operator[] ( size_type  pos) const
inline

ValueProxy handles the conversion to int and ,the writing ( if != sparseElement )

Referenced by SparseVector< float >::at(), and SparseVector< float >::push_back().

◆ operator[]() [2/2]

ValueProxy operator[] ( size_type  pos)
inline

ValueProxy handles the conversion and the writing ( if != sparseElement )

◆ print()

void print ( ) const
inline

◆ push_back()

void push_back ( Value  value)
inline

push_back (see stl vector docs)

◆ rbegin() [1/2]

reverse_iterator rbegin ( )
inline

rbegin iterator

◆ rbegin() [2/2]

const_reverse_iterator rbegin ( ) const
inline

const begin reverse_iterator

◆ rend() [1/2]

reverse_iterator rend ( )
inline

rend iterator

◆ rend() [2/2]

const_reverse_iterator rend ( ) const
inline

const end reverse_iterator

◆ resize()

void resize ( size_type  newsize)
inline

resizes the vector to param newsize

◆ size()

size_type size ( ) const
inline

◆ update_()

void update_ ( map_iterator  it,
Size  amount_deleted 
)
inlineprotected

Updates position of it and all larger elements.

Referenced by SparseVector< float >::erase().

Member Data Documentation

◆ size_

size_type size_
private

◆ sparse_element_

Value sparse_element_
protected

◆ values_

std::map<size_type, Value> values_
private

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:12 using doxygen 1.8.13