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

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 150 of file bmsparsevec.h.

Member Typedef Documentation

◆ allocator_pool_type

Definition at line 164 of file bmsparsevec.h.

◆ allocator_type

template<class Val, class BV>
typedef bvector_type::allocator_type bm::sparse_vector< Val, BV >::const_iterator::allocator_type

Definition at line 163 of file bmsparsevec.h.

◆ buffer_type

template<class Val, class BV>
typedef bm::byte_buffer<allocator_type> bm::sparse_vector< Val, BV >::const_iterator::buffer_type

Definition at line 165 of file bmsparsevec.h.

◆ bvector_type

template<class Val, class BV>
typedef sparse_vector_type::bvector_type bm::sparse_vector< Val, BV >::const_iterator::bvector_type

Definition at line 162 of file bmsparsevec.h.

◆ difference_type

template<class Val, class BV>
typedef unsigned bm::sparse_vector< Val, BV >::const_iterator::difference_type

Definition at line 167 of file bmsparsevec.h.

◆ iterator_category

template<class Val, class BV>
typedef std::input_iterator_tag bm::sparse_vector< Val, BV >::const_iterator::iterator_category

Definition at line 156 of file bmsparsevec.h.

◆ pointer

template<class Val, class BV>
typedef unsigned* bm::sparse_vector< Val, BV >::const_iterator::pointer

Definition at line 168 of file bmsparsevec.h.

◆ reference

template<class Val, class BV>
typedef value_type& bm::sparse_vector< Val, BV >::const_iterator::reference

Definition at line 169 of file bmsparsevec.h.

◆ size_type

template<class Val, class BV>
typedef sparse_vector_type::size_type bm::sparse_vector< Val, BV >::const_iterator::size_type

Definition at line 161 of file bmsparsevec.h.

◆ sparse_vector_type

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

Definition at line 158 of file bmsparsevec.h.

◆ sparse_vector_type_ptr

template<class Val, class BV>
typedef sparse_vector_type* bm::sparse_vector< Val, BV >::const_iterator::sparse_vector_type_ptr

Definition at line 159 of file bmsparsevec.h.

◆ value_type

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

Definition at line 160 of file bmsparsevec.h.

Constructor & Destructor Documentation

◆ const_iterator() [1/4]

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

◆ const_iterator() [2/4]

template<class Val, class BV>
bm::sparse_vector< Val, BV >::const_iterator::const_iterator ( const sparse_vector_type sv)

◆ const_iterator() [3/4]

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

◆ const_iterator() [4/4]

template<class Val, class BV>
bm::sparse_vector< Val, BV >::const_iterator::const_iterator ( const const_iterator it)

Member Function Documentation

◆ advance()

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

advance iterator forward by one

Definition at line 1979 of file bmsparsevec.h.

References bm::id_max, bm::sparse_vector< Val, BV >::const_iterator::invalidate(), and bm::sparse_vector< Val, BV >::size().

◆ 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 1970 of file bmsparsevec.h.

References bm::id_max, and bm::sparse_vector< Val, BV >::size().

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

◆ invalidate()

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

Invalidate current iterator.

Definition at line 212 of file bmsparsevec.h.

References bm::id_max.

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

◆ is_null()

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

Get NULL status.

Definition at line 2047 of file bmsparsevec.h.

References bm::base_sparse_vector< Val, BV, MAX_SIZE >::is_null().

◆ operator!=()

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

Definition at line 179 of file bmsparsevec.h.

◆ 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 191 of file bmsparsevec.h.

◆ 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 195 of file bmsparsevec.h.

◆ 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 198 of file bmsparsevec.h.

References bm::base_sparse_vector< Val, BV, 1 >::is_null().

◆ operator<()

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

Definition at line 181 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

Definition at line 183 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

Definition at line 177 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

Definition at line 185 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

Definition at line 187 of file bmsparsevec.h.

◆ 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 215 of file bmsparsevec.h.

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

◆ skip_zero_values()

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

◆ 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 209 of file bmsparsevec.h.

References bm::id_max.

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

◆ value()

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

Friends And Related Function Documentation

◆ sparse_vector

template<class Val, class BV>
friend class sparse_vector
friend

Definition at line 153 of file bmsparsevec.h.


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