BitMagic-C++
Public Types | Public Member Functions | Friends
bm::sparse_vector< Val, BV >::const_iterator Class Reference

Const iterator to traverse the sparse vector. More...

#include <bmsparsevec.h>

Public Types

typedef std::input_iterator_tag iterator_category
 
typedef sparse_vector< Val, BV > sparse_vector_type
 
typedef sparse_vector_typesparse_vector_type_ptr
 
typedef sparse_vector_type::value_type value_type
 
typedef sparse_vector_type::size_type size_type
 
typedef sparse_vector_type::bvector_type bvector_type
 
typedef bvector_type::allocator_type allocator_type
 
typedef bvector_type::allocator_type::allocator_pool_type allocator_pool_type
 
typedef bm::byte_buffer< allocator_typebuffer_type
 
typedef unsigned difference_type
 
typedef unsigned * pointer
 
typedef value_typereference
 

Public Member Functions

 const_iterator () BMNOEXCEPT
  More...
 
 const_iterator (const sparse_vector_type *sv) BMNOEXCEPT
 
 const_iterator (const sparse_vector_type *sv, size_type pos) BMNOEXCEPT
 
 const_iterator (const const_iterator &it) BMNOEXCEPT
 
bool operator== (const const_iterator &it) const BMNOEXCEPT
  More...
 
bool operator!= (const const_iterator &it) const BMNOEXCEPT
  More...
 
bool operator< (const const_iterator &it) const BMNOEXCEPT
 
bool operator<= (const const_iterator &it) const BMNOEXCEPT
 
bool operator> (const const_iterator &it) const BMNOEXCEPT
 
bool operator>= (const const_iterator &it) const BMNOEXCEPT
 
value_type operator* () const
 Get current position (value) More...
 
const_iteratoroperator++ () BMNOEXCEPT
 Advance to the next available value. More...
 
const_iterator operator++ (int)
 Advance to the next available value. More...
 
value_type value () const
 Get current position (value) More...
 
bool is_null () const BMNOEXCEPT
 Get NULL status. More...
 
bool valid () const BMNOEXCEPT
 Returns true if iterator is at a valid position. More...
 
void invalidate () BMNOEXCEPT
 Invalidate current iterator. More...
 
size_type pos () const BMNOEXCEPT
 Current position (index) in the vector. More...
 
void go_to (size_type pos) BMNOEXCEPT
 re-position to a specified position More...
 
bool advance () BMNOEXCEPT
 advance iterator forward by one More...
 
void skip_zero_values () BMNOEXCEPT
  More...
 

Friends

class sparse_vector
 

Detailed Description

template<class Val, class BV>
class bm::sparse_vector< Val, BV >::const_iterator

Const iterator to traverse the sparse vector.

Implementation uses buffer for decoding so, competing changes to the original vector may not match the iterator returned values.

This iterator keeps an operational buffer for 8K elements, so memory footprint is not negligable (about 64K for unsigned int)

Definition at line 157 of file bmsparsevec.h.

Member Function Documentation

◆ advance()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::const_iterator::advance

advance iterator forward by one

Returns
true if it is still valid

Definition at line 2326 of file bmsparsevec.h.

References bm::id_max, and bm::sparse_vector< Val, BV >::n_buf_size.

Referenced by bm::sparse_vector< Val, BV >::const_iterator::operator++().

◆ go_to()

template<class Val , class BV >
void bm::sparse_vector< Val, BV >::const_iterator::go_to ( size_type  pos)

re-position to a specified position

Definition at line 2317 of file bmsparsevec.h.

References bm::id_max.

◆ invalidate()

template<class Val , class BV >
void bm::sparse_vector< Val, BV >::const_iterator::invalidate ( )
inline

Invalidate current iterator.

Definition at line 221 of file bmsparsevec.h.

References bm::id_max.

◆ is_null()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::const_iterator::is_null

Get NULL status.

Definition at line 2395 of file bmsparsevec.h.

◆ operator!=()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::const_iterator::operator!= ( const const_iterator it) const
inline

◆ operator*()

template<class Val , class BV >
value_type bm::sparse_vector< Val, BV >::const_iterator::operator* ( ) const
inline

Get current position (value)

Definition at line 199 of file bmsparsevec.h.

References bm::sparse_vector< Val, BV >::const_iterator::value().

◆ operator++() [1/2]

template<class Val , class BV >
const_iterator& bm::sparse_vector< Val, BV >::const_iterator::operator++ ( )
inline

Advance to the next available value.

Definition at line 203 of file bmsparsevec.h.

References bm::sparse_vector< Val, BV >::const_iterator::advance().

◆ operator++() [2/2]

template<class Val , class BV >
const_iterator bm::sparse_vector< Val, BV >::const_iterator::operator++ ( int  )
inline

Advance to the next available value.

Definition at line 207 of file bmsparsevec.h.

References bm::sparse_vector< Val, BV >::const_iterator::advance().

◆ operator==()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::const_iterator::operator== ( const const_iterator it) const
inline

◆ pos()

template<class Val , class BV >
size_type bm::sparse_vector< Val, BV >::const_iterator::pos ( ) const
inline

Current position (index) in the vector.

Definition at line 224 of file bmsparsevec.h.

◆ skip_zero_values()

template<class Val , class BV >
void bm::sparse_vector< Val, BV >::const_iterator::skip_zero_values

Definition at line 2367 of file bmsparsevec.h.

References bm::id_max, and bm::sparse_vector< Val, BV >::n_buf_size.

◆ valid()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::const_iterator::valid ( ) const
inline

Returns true if iterator is at a valid position.

Definition at line 218 of file bmsparsevec.h.

References bm::id_max.

◆ value()

template<class Val , class BV >
sparse_vector< Val, BV >::const_iterator::value_type bm::sparse_vector< Val, BV >::const_iterator::value

Get current position (value)

Definition at line 2349 of file bmsparsevec.h.

References BM_ASSERT, and bm::sparse_vector< Val, BV >::n_buf_size.

Referenced by bm::sparse_vector< Val, BV >::const_iterator::operator*().


The documentation for this class was generated from the following file: