BitMagic-C++
bm::bvector< Alloc >::enumerator Class Reference

Constant iterator designed to enumerate "ON" bits. More...

#include <bm.h>

Inheritance diagram for bm::bvector< Alloc >::enumerator:
Collaboration diagram for bm::bvector< Alloc >::enumerator:

Public Types

typedef std::input_iterator_tag iterator_category
typedef size_type value_type
typedef unsigned difference_type
typedef unsigned * pointer
typedef unsigned & reference

Public Member Functions

 enumerator () BMNOEXCEPT
 enumerator (const bvector< Alloc > *bv) BMNOEXCEPT
 Construct enumerator associated with a vector. Important: This construction creates unpositioned iterator with status valid() == false. It can be re-positioned using go_first() or go_to().
 enumerator (const bvector< Alloc > &bv, size_type pos=0) BMNOEXCEPT
 Construct enumerator for bit vector.
 enumerator (const bvector< Alloc > *bv, size_type pos) BMNOEXCEPT
 Construct enumerator for bit vector.
size_type operator* () const BMNOEXCEPT
 Get current position (value).
size_type value () const BMNOEXCEPT
 Get current position (value).
enumeratoroperator++ () BMNOEXCEPT
 Advance enumerator forward to the next available bit.
enumerator operator++ (int) BMNOEXCEPT
 Advance enumerator forward to the next available bit. Possibly do NOT use this operator it is slower than the pre-fix increment.
void go_first () BMNOEXCEPT
 Position enumerator to the first available bit.
bool advance () BMNOEXCEPT
bool go_up () BMNOEXCEPT
 Advance enumerator to the next available bit.
bool skip_to_rank (size_type rank) BMNOEXCEPT
 Skip to specified relative rank.
bool skip (size_type rank) BMNOEXCEPT
 Skip specified number of bits from enumeration.
bool go_to (size_type pos) BMNOEXCEPT
 go to a specific position in the bit-vector (or next)
Public Member Functions inherited from bm::bvector< Alloc >::iterator_base
 iterator_base () BMNOEXCEPT
bool operator== (const iterator_base &it) const BMNOEXCEPT
bool operator!= (const iterator_base &it) const BMNOEXCEPT
bool operator< (const iterator_base &it) const BMNOEXCEPT
bool operator<= (const iterator_base &it) const BMNOEXCEPT
bool operator> (const iterator_base &it) const BMNOEXCEPT
bool operator>= (const iterator_base &it) const BMNOEXCEPT
bool valid () const BMNOEXCEPT
 Checks if iterator is still valid.
void invalidate () BMNOEXCEPT
 Turns iterator into an invalid state.
bool compare_state (const iterator_base &ib) const BMNOEXCEPT
 Compare FSMs for testing purposes.

Additional Inherited Members

Protected Attributes inherited from bm::bvector< Alloc >::iterator_base
bm::bvector< Alloc > * bv_
 Pointer on parent bitvector.
size_type position_
 Bit position (bit idx).
const bm::word_tblock_
 Block pointer.(NULL-invalid).
unsigned block_type_
 Type of block. 0-Bit, 1-GAP.
block_idx_type block_idx_
 Block index.
union bm::bvector::iterator_base::block_descr bdescr_

Detailed Description

template<class Alloc>
class bm::bvector< Alloc >::enumerator

Constant iterator designed to enumerate "ON" bits.

Examples
bv3vlogic.cpp, bvsample01_64.cpp, bvsetalgebra.cpp, sample24.cpp, sample5.cpp, sample8.cpp, svsample04.cpp, svsample05.cpp, svsample06.cpp, xsample01.cpp, xsample03.cpp, xsample07.cpp, and xsample07a.cpp.

Definition at line 602 of file bm.h.

Member Typedef Documentation

◆ difference_type

template<class Alloc>
typedef unsigned bm::bvector< Alloc >::enumerator::difference_type

Definition at line 609 of file bm.h.

◆ iterator_category

template<class Alloc>
typedef std::input_iterator_tag bm::bvector< Alloc >::enumerator::iterator_category

Definition at line 606 of file bm.h.

◆ pointer

template<class Alloc>
typedef unsigned* bm::bvector< Alloc >::enumerator::pointer

Definition at line 610 of file bm.h.

◆ reference

template<class Alloc>
typedef unsigned& bm::bvector< Alloc >::enumerator::reference

Definition at line 611 of file bm.h.

◆ value_type

template<class Alloc>
typedef size_type bm::bvector< Alloc >::enumerator::value_type

Definition at line 608 of file bm.h.

Constructor & Destructor Documentation

◆ enumerator() [1/4]

◆ enumerator() [2/4]

template<class Alloc>
bm::bvector< Alloc >::enumerator::enumerator ( const bvector< Alloc > * bv)
inline

Construct enumerator associated with a vector. Important: This construction creates unpositioned iterator with status valid() == false. It can be re-positioned using go_first() or go_to().

See also
go_to

Definition at line 622 of file bm.h.

References BMNOEXCEPT, bm::bvector< Alloc >::iterator_base::bv_, and bm::bvector< Alloc >::iterator_base::bvector.

◆ enumerator() [3/4]

template<class Alloc>
bm::bvector< Alloc >::enumerator::enumerator ( const bvector< Alloc > & bv,
size_type pos = 0 )
inline

Construct enumerator for bit vector.

Parameters
bvbit-vector reference
posbit position in the vector if position is 0, it finds the next 1 or becomes not valid (en.valid() == false)

Definition at line 634 of file bm.h.

References BMNOEXCEPT, bm::bvector< Alloc >::iterator_base::bv_, bm::bvector< Alloc >::iterator_base::bvector, go_to(), and bm::bvector< Alloc >::iterator_base::iterator_base().

◆ enumerator() [4/4]

template<class Alloc>
bm::bvector< Alloc >::enumerator::enumerator ( const bvector< Alloc > * bv,
size_type pos )
inline

Construct enumerator for bit vector.

Parameters
bvbit-vector pointer
posbit position in the vector if position is 0, it finds the next 1 or becomes not valid (en.valid() == false)

Definition at line 648 of file bm.h.

References BMNOEXCEPT, bm::bvector< Alloc >::iterator_base::bv_, bm::bvector< Alloc >::iterator_base::bvector, and go_to().

Member Function Documentation

◆ advance()

template<class Alloc>
bool bm::bvector< Alloc >::enumerator::advance ( )
inline

advance iterator forward by one

Returns
true if advance was successfull and the enumerator is valid

Definition at line 680 of file bm.h.

References advance(), BMNOEXCEPT, and go_up().

Referenced by advance(), bm::rsc_sparse_vector< Val, SV >::decode(), and bm::rsc_sparse_vector< Val, SV >::decode_buf().

◆ go_first()

◆ go_to()

◆ go_up()

◆ operator*()

template<class Alloc>
size_type bm::bvector< Alloc >::enumerator::operator* ( ) const
inline

Get current position (value).

Definition at line 656 of file bm.h.

References BMNOEXCEPT, and bm::bvector< Alloc >::iterator_base::position_.

◆ operator++() [1/2]

template<class Alloc>
enumerator & bm::bvector< Alloc >::enumerator::operator++ ( )
inline

Advance enumerator forward to the next available bit.

Definition at line 662 of file bm.h.

References BMNOEXCEPT, enumerator(), and go_up().

◆ operator++() [2/2]

template<class Alloc>
enumerator bm::bvector< Alloc >::enumerator::operator++ ( int )
inline

Advance enumerator forward to the next available bit. Possibly do NOT use this operator it is slower than the pre-fix increment.

Definition at line 667 of file bm.h.

References BMNOEXCEPT, enumerator(), and go_up().

◆ skip()

◆ skip_to_rank()

template<class Alloc>
bool bm::bvector< Alloc >::enumerator::skip_to_rank ( size_type rank)
inline

Skip to specified relative rank.

Parameters
rank- number of ON bits to go for (must be: > 0)
Returns
true if skip was successfull and enumerator is valid

Definition at line 690 of file bm.h.

References BM_ASSERT, BMNOEXCEPT, bm::bvector< Alloc >::rank(), skip(), skip_to_rank(), and bm::bvector< Alloc >::iterator_base::valid().

Referenced by skip_to_rank().

◆ value()

template<class Alloc>
size_type bm::bvector< Alloc >::enumerator::value ( ) const
inline

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