Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

SparseVector< Value > Class Template Reference
[Datastructures]

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>

List of all members.

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

Protected Member Functions

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

Protected Attributes

Value sparse_element_
 sparse element

Private Attributes

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

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, DoubleReal, Real. 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

typedef std::map<size_t, Value>::allocator_type allocator_type
typedef const ValueProxy& const_reference
typedef std::map<size_t, Value>::difference_type difference_type
typedef std::map<size_t, Value>::const_iterator map_const_iterator
typedef std::map<size_t, Value>::iterator map_iterator
typedef Value* pointer
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 std::map<size_t, Value>::size_type size_type
typedef Value value_type

Constructor & Destructor Documentation

SparseVector (  )  [inline]

default constructor

SparseVector ( Value  se  )  [inline]

constructor with chosen sparse element

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 ( const SparseVector< Value > &  source  )  [inline]

copy constructor

~SparseVector (  )  [inline]

destructor


Member Function Documentation

Value at ( size_type  pos  )  const [inline]

at (see stl vector docs)

Parameters:
pos index at which the desired element stays
Exceptions:
OutOfRange is thrown if the index is greater or equal than the size of the vector
iterator begin (  )  [inline]

begin iterator

Referenced by SparseVector< Real >::getMinElement().

const_iterator begin (  )  const [inline]

const begin iterator

void clear (  )  [inline]

removes all elements

bool empty (  )  const [inline]

true if the container is empty

iterator end (  )  [inline]

end iterator

Referenced by SparseVector< Real >::getMinElement().

const_iterator end (  )  const [inline]

const end iterator

void erase ( SparseVectorIterator  it  )  [inline]

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

Parameters:
it parameter which specifies the element which should be deleted
Exceptions:
OutOfRange is thrown if the iterator does not point to an element
void erase ( SparseVectorIterator  first,
SparseVectorIterator  last 
) [inline]

erase indicated element(halfopen iterator-range) and imediately update indices in map

Parameters:
first iterator that points to the begin of the range which should be erased
last iterator that points one position behind the last position which should be erased
SparseVectorIterator getMinElement (  )  [inline]

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

size_type nonzero_size (  )  const [inline]

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

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

less than operator

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

assignment operator

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

equality operator

const Value operator[] ( size_type  pos  )  const [inline]

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

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

ValueProxy operator[] ( size_type  pos  )  [inline]

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

void print (  )  const [inline]
void push_back ( Value  value  )  [inline]

push_back (see stl vector docs)

const_reverse_iterator rbegin (  )  const [inline]

const begin reverse_iterator

reverse_iterator rbegin (  )  [inline]

rbegin iterator

reverse_iterator rend (  )  [inline]

rend iterator

const_reverse_iterator rend (  )  const [inline]

const end reverse_iterator

void resize ( size_type  newsize  )  [inline]

resizes the the vector to param newsize

size_type size (  )  const [inline]
void update_ ( map_iterator  it,
Size  amount_deleted 
) [inline, protected]

Updates position of it and all larger elements.

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


Member Data Documentation

size_type size_ [private]
Value sparse_element_ [protected]
std::map<size_type, Value> values_ [private]

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:53 using doxygen 1.7.1