NCBI C++ ToolKit
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | List of all members
bm::bvector< Alloc >::enumerator Class Reference

Search Toolkit Book for bm::bvector::enumerator

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

#include <util/bitset/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 () noexcept
 
 enumerator (const bvector< Alloc > *bv) noexcept
 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(). More...
 
 enumerator (const bvector< Alloc > &bv, size_type pos=0) noexcept
 Construct enumerator for bit vector. More...
 
 enumerator (const bvector< Alloc > *bv, size_type pos) noexcept
 Construct enumerator for bit vector. More...
 
size_type operator* () const noexcept
 Get current position (value) More...
 
size_type value () const noexcept
 Get current position (value) More...
 
enumeratoroperator++ () noexcept
 Advance enumerator forward to the next available bit. More...
 
enumerator operator++ (int) noexcept
 Advance enumerator forward to the next available bit. Possibly do NOT use this operator it is slower than the pre-fix increment. More...
 
void go_first () noexcept
 Position enumerator to the first available bit. More...
 
bool advance () noexcept
 
bool go_up () noexcept
 Advance enumerator to the next available bit. More...
 
bool skip_to_rank (size_type rank) noexcept
 Skip to specified relative rank. More...
 
bool skip (size_type rank) noexcept
 Skip specified number of bits from enumeration. More...
 
bool go_to (size_type pos) noexcept
 go to a specific position in the bit-vector (or next) More...
 
- Public Member Functions inherited from bm::bvector< Alloc >::iterator_base
 iterator_base () noexcept
 
bool operator== (const iterator_base &it) const noexcept
 
bool operator!= (const iterator_base &it) const noexcept
 
bool operator< (const iterator_base &it) const noexcept
 
bool operator<= (const iterator_base &it) const noexcept
 
bool operator> (const iterator_base &it) const noexcept
 
bool operator>= (const iterator_base &it) const noexcept
 
bool valid () const noexcept
 Checks if iterator is still valid. More...
 
void invalidate () noexcept
 Turns iterator into an invalid state. More...
 
bool compare_state (const iterator_base &ib) const noexcept
 Compare FSMs for testing purposes. More...
 

Private Types

typedef iterator_base::block_descr block_descr_type
 

Private Member Functions

bool decode_bit_group (block_descr_type *bdescr) noexcept
 
bool decode_bit_group (block_descr_type *bdescr, size_type &rank) noexcept
 
bool search_in_bitblock () noexcept
 
bool search_in_gapblock () noexcept
 
bool search_in_blocks () noexcept
 

Static Private Member Functions

static bool decode_wave (block_descr_type *bdescr) noexcept
 

Additional Inherited Members

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

Definition at line 602 of file bm.h.

Member Typedef Documentation

◆ block_descr_type

template<class Alloc >
typedef iterator_base::block_descr bm::bvector< Alloc >::enumerator::block_descr_type
private

Definition at line 712 of file bm.h.

◆ 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]

template<class Alloc >
bm::bvector< Alloc >::enumerator::enumerator ( )
inlinenoexcept

◆ enumerator() [2/4]

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

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.

◆ enumerator() [3/4]

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

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.

◆ enumerator() [4/4]

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

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.

Member Function Documentation

◆ advance()

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

advance iterator forward by one

Returns
true if advance was successfull and the enumerator is valid

Definition at line 680 of file bm.h.

◆ decode_bit_group() [1/2]

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::decode_bit_group ( block_descr_type bdescr)
privatenoexcept

◆ decode_bit_group() [2/2]

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::decode_bit_group ( block_descr_type bdescr,
size_type rank 
)
privatenoexcept

◆ decode_wave()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::decode_wave ( block_descr_type bdescr)
staticprivatenoexcept

Definition at line 8361 of file bm.h.

References bm::bitscan_wave().

Referenced by bm::bvector< Alloc >::enumerator::decode_bit_group().

◆ go_first()

template<class Alloc >
void bm::bvector< Alloc >::enumerator::go_first
noexcept

◆ go_to()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::go_to ( size_type  pos)
noexcept

go to a specific position in the bit-vector (or next)

Definition at line 8209 of file bm.h.

References bm::bvector< Alloc >::iterator_base::bdescr_, bm::bvector< Alloc >::iterator_base::block_descr::bit_, bm::bvector< Alloc >::iterator_base::bitblock_descr::bits, bm::bitscan_wave(), bm::bvector< Alloc >::iterator_base::block_, bm::bvector< Alloc >::iterator_base::block_idx_, bm::bvector< Alloc >::iterator_base::block_type_, BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bool, bm::bvector< Alloc >::iterator_base::bv_, bm::bvector< Alloc >::iterator_base::bitblock_descr::cnt, bm::bvector< Alloc >::iterator_base::block_descr::gap_, bm::gap_bfind(), bm::bvector< Alloc >::iterator_base::dgap_descr::gap_len, bm::blocks_manager< Alloc >::get_block(), bm::get_block_coord(), bm::bvector< Alloc >::enumerator::go_first(), i, bm::bvector< Alloc >::iterator_base::bitblock_descr::idx, bm::bvector< Alloc >::iterator_base::invalidate(), bm::bvector< Alloc >::iterator_base::bitblock_descr::pos, bm::bvector< Alloc >::iterator_base::position_, bm::bvector< Alloc >::iterator_base::bitblock_descr::ptr, bm::bvector< Alloc >::iterator_base::dgap_descr::ptr, bm::bvector< Alloc >::enumerator::search_in_bitblock(), bm::bvector< Alloc >::enumerator::search_in_gapblock(), bm::set_bitscan_wave_size, bm::set_block_mask, bm::set_block_shift, bm::set_block_size, bm::set_word_mask, bm::set_word_shift, and bm::bvector< Alloc >::iterator_base::valid().

Referenced by BVectorErase(), bm::bvector< >::enumerator::enumerator(), EnumeratorTest(), TestCompressSparseSignedVector(), and TestCompressSparseVector().

◆ go_up()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::go_up
noexcept

◆ operator*()

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

Get current position (value)

Definition at line 656 of file bm.h.

◆ operator++() [1/2]

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

Advance enumerator forward to the next available bit.

Definition at line 662 of file bm.h.

◆ operator++() [2/2]

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

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.

◆ search_in_bitblock()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::search_in_bitblock
privatenoexcept

◆ search_in_blocks()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::search_in_blocks
privatenoexcept

◆ search_in_gapblock()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::search_in_gapblock
privatenoexcept

◆ skip()

template<class Alloc >
bool bm::bvector< Alloc >::enumerator::skip ( size_type  rank)
noexcept

◆ skip_to_rank()

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

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.

◆ value()

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

Get current position (value)

Definition at line 659 of file bm.h.

Referenced by bm::bvector< Alloc >::insert(), and bm::bvector< Alloc >::set_range().


The documentation for this class was generated from the following file:
Modified on Wed Jun 12 11:14:33 2024 by modify_doxy.py rev. 669887