BitMagic-C++
Public Types | Public Member Functions | Protected Types | Protected Member Functions
bm::interval_enumerator< BV > Class Template Reference

forward iterator class to traverse bit-vector as ranges More...

#include <bmintervals.h>

Public Types

typedef std::input_iterator_tag iterator_category
 
typedef BV bvector_type
 
typedef bvector_type::size_type size_type
 
typedef bvector_type::allocator_type allocator_type
 
typedef bm::byte_buffer< allocator_typebuffer_type
 
typedef bm::pair< size_type, size_typepair_type
 

Public Member Functions

size_type start () const BMNOEXCEPT
 Return interval start/left as bit-vector coordinate 011110 [left..right]. More...
 
size_type end () const BMNOEXCEPT
 Return interval end/right as bit-vector coordinate 011110 [left..right]. More...
 
const pair_typeoperator* () const BMNOEXCEPT
 
const pair_typeget () const BMNOEXCEPT
 Get interval pair. More...
 
bool valid () const BMNOEXCEPT
 Returns true if enumerator is valid (false if traversal is done) More...
 
void swap (interval_enumerator< BV > &ien) BMNOEXCEPT
 swap enumerator with another one More...
 
Construction and assignment
 interval_enumerator ()
 
 interval_enumerator (const BV &bv)
 Construct enumerator for the bit-vector. More...
 
 interval_enumerator (const BV &bv, size_type start_pos, bool extend_start)
 Construct enumerator for the specified position. More...
 
 interval_enumerator (const interval_enumerator< BV > &ien)
 Copy constructor. More...
 
interval_enumeratoroperator= (const interval_enumerator< BV > &ien)
 Assignment operator. More...
 
 interval_enumerator (interval_enumerator< BV > &&ien) BMNOEXCEPT
 move-ctor More...
 
interval_enumerator< BV > & operator= (interval_enumerator< BV > &&ien) BMNOEXCEPT
 move assignmment operator More...
 
Comparison methods all use start position to compare
bool operator== (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
bool operator!= (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
bool operator< (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
bool operator<= (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
bool operator> (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
bool operator>= (const interval_enumerator< BV > &ien) const BMNOEXCEPT
 
enumerator positioning
bool go_to (size_type pos, bool extend_start=true)
 Go to inetrval at specified position Jump to position with interval. If interval is not available at the specified position (o bit) enumerator will find the next interval. If interval is present we have an option to find interval start [left..] and set enumerator from the effective start coodrinate. More...
 
bool advance ()
 
interval_enumerator< BV > & operator++ () BMNOEXCEPT
 Advance enumerator forward to the next available bit. More...
 
interval_enumerator< BV > operator++ (int) BMNOEXCEPT
 Advance enumerator forward to the next available bit. More...
 

Protected Types

typedef bvector_type::block_idx_type block_idx_type
 
typedef bvector_type::allocator_type bv_allocator_type
 
typedef bm::heap_vector< unsigned short, bv_allocator_type, true > gap_vector_type
 

Protected Member Functions

bool go_to_impl (size_type pos, bool extend_start)
 
void invalidate () BMNOEXCEPT
 Turn FSM into invalid state (out of range) More...
 

Detailed Description

template<typename BV>
class bm::interval_enumerator< BV >

forward iterator class to traverse bit-vector as ranges

Traverse enumerator for forward walking bit-vector as intervals: series of consequtive 1111s flanked with zeroes. Enumerator can traverse the whole bit-vector or jump(go_to) to position.

Examples:
sample23.cpp, and xsample08.cpp.

Definition at line 52 of file bmintervals.h.

Member Typedef Documentation

◆ allocator_type

Definition at line 60 of file bmintervals.h.

◆ block_idx_type

template<typename BV>
typedef bvector_type::block_idx_type bm::interval_enumerator< BV >::block_idx_type
protected

Definition at line 210 of file bmintervals.h.

◆ buffer_type

template<typename BV>
typedef bm::byte_buffer<allocator_type> bm::interval_enumerator< BV >::buffer_type

Definition at line 61 of file bmintervals.h.

◆ bv_allocator_type

template<typename BV>
typedef bvector_type::allocator_type bm::interval_enumerator< BV >::bv_allocator_type
protected

Definition at line 211 of file bmintervals.h.

◆ bvector_type

template<typename BV>
typedef BV bm::interval_enumerator< BV >::bvector_type

Definition at line 58 of file bmintervals.h.

◆ gap_vector_type

template<typename BV>
typedef bm::heap_vector<unsigned short, bv_allocator_type, true> bm::interval_enumerator< BV >::gap_vector_type
protected

Definition at line 213 of file bmintervals.h.

◆ iterator_category

template<typename BV>
typedef std::input_iterator_tag bm::interval_enumerator< BV >::iterator_category

Definition at line 56 of file bmintervals.h.

◆ pair_type

template<typename BV>
typedef bm::pair<size_type, size_type> bm::interval_enumerator< BV >::pair_type

Definition at line 62 of file bmintervals.h.

◆ size_type

template<typename BV>
typedef bvector_type::size_type bm::interval_enumerator< BV >::size_type

Definition at line 59 of file bmintervals.h.

Constructor & Destructor Documentation

◆ interval_enumerator() [1/5]

template<typename BV>
bm::interval_enumerator< BV >::interval_enumerator ( )
inline

Definition at line 68 of file bmintervals.h.

◆ interval_enumerator() [2/5]

template<typename BV>
bm::interval_enumerator< BV >::interval_enumerator ( const BV &  bv)
inline

Construct enumerator for the bit-vector.

Definition at line 75 of file bmintervals.h.

References bm::interval_enumerator< BV >::go_to_impl().

◆ interval_enumerator() [3/5]

template<typename BV>
bm::interval_enumerator< BV >::interval_enumerator ( const BV &  bv,
size_type  start_pos,
bool  extend_start 
)
inline

Construct enumerator for the specified position.

Parameters
bv- source bit-vector
start_pos- position on bit-vector to search for interval
extend_start- flag to extend interval start to the start if true start happenes to be less than start_pos
See also
go_to

Definition at line 89 of file bmintervals.h.

References bm::interval_enumerator< BV >::go_to_impl().

◆ interval_enumerator() [4/5]

template<typename BV>
bm::interval_enumerator< BV >::interval_enumerator ( const interval_enumerator< BV > &  ien)
inline

Copy constructor.

Definition at line 98 of file bmintervals.h.

References bm::interval_enumerator< BV >::go_to_impl(), and bm::interval_enumerator< BV >::start().

◆ interval_enumerator() [5/5]

template<typename BV>
bm::interval_enumerator< BV >::interval_enumerator ( interval_enumerator< BV > &&  ien)
inline

move-ctor

Definition at line 115 of file bmintervals.h.

References bm::interval_enumerator< BV >::swap().

Member Function Documentation

◆ advance()

template<typename BV >
bool bm::interval_enumerator< BV >::advance ( )

◆ end()

template<typename BV >
interval_enumerator< BV >::size_type bm::interval_enumerator< BV >::end ( ) const

Return interval end/right as bit-vector coordinate 011110 [left..right].

Examples:
sample23.cpp, and xsample08.cpp.

Definition at line 560 of file bmintervals.h.

References bm::pair< First, Second >::second.

Referenced by main(), bm::interval_enumerator< BV >::operator>=(), and print_model().

◆ get()

template<typename BV>
const pair_type& bm::interval_enumerator< BV >::get ( ) const
inline

◆ go_to()

template<typename BV >
bool bm::interval_enumerator< BV >::go_to ( size_type  pos,
bool  extend_start = true 
)

Go to inetrval at specified position Jump to position with interval. If interval is not available at the specified position (o bit) enumerator will find the next interval. If interval is present we have an option to find interval start [left..] and set enumerator from the effective start coodrinate.

Parameters
pos- position on bit-vector
extend_start- find effective start if it is less than the go to position
Returns
true if enumerator remains valid after the jump
Examples:
sample23.cpp.

Definition at line 584 of file bmintervals.h.

References bm::interval_enumerator< BV >::go_to_impl().

Referenced by bm::interval_enumerator< BV >::get(), and main().

◆ go_to_impl()

template<typename BV >
bool bm::interval_enumerator< BV >::go_to_impl ( size_type  pos,
bool  extend_start 
)
protected

◆ invalidate()

template<typename BV >
void bm::interval_enumerator< BV >::invalidate ( )
protected

Turn FSM into invalid state (out of range)

Definition at line 576 of file bmintervals.h.

References bm::pair< First, Second >::first, bm::id_max, and bm::pair< First, Second >::second.

Referenced by bm::interval_enumerator< BV >::advance(), and bm::interval_enumerator< BV >::go_to_impl().

◆ operator!=()

template<typename BV>
bool bm::interval_enumerator< BV >::operator!= ( const interval_enumerator< BV > &  ien) const
inline

Definition at line 140 of file bmintervals.h.

References bm::interval_enumerator< BV >::start().

◆ operator*()

template<typename BV>
const pair_type& bm::interval_enumerator< BV >::operator* ( ) const
inline

Definition at line 158 of file bmintervals.h.

◆ operator++() [1/2]

template<typename BV>
interval_enumerator<BV>& bm::interval_enumerator< BV >::operator++ ( )
inline

Advance enumerator forward to the next available bit.

Definition at line 192 of file bmintervals.h.

References bm::interval_enumerator< BV >::advance().

◆ operator++() [2/2]

template<typename BV>
interval_enumerator<BV> bm::interval_enumerator< BV >::operator++ ( int  )
inline

Advance enumerator forward to the next available bit.

Definition at line 196 of file bmintervals.h.

References bm::interval_enumerator< BV >::advance(), BMNOEXCEPT, and bm::interval_enumerator< BV >::swap().

◆ operator<()

template<typename BV>
bool bm::interval_enumerator< BV >::operator< ( const interval_enumerator< BV > &  ien) const
inline

Definition at line 142 of file bmintervals.h.

References bm::interval_enumerator< BV >::start().

◆ operator<=()

template<typename BV>
bool bm::interval_enumerator< BV >::operator<= ( const interval_enumerator< BV > &  ien) const
inline

Definition at line 144 of file bmintervals.h.

References bm::interval_enumerator< BV >::start().

◆ operator=() [1/2]

template<typename BV>
interval_enumerator& bm::interval_enumerator< BV >::operator= ( const interval_enumerator< BV > &  ien)
inline

Assignment operator.

Definition at line 107 of file bmintervals.h.

References bm::interval_enumerator< BV >::go_to_impl(), and bm::interval_enumerator< BV >::start().

◆ operator=() [2/2]

template<typename BV>
interval_enumerator<BV>& bm::interval_enumerator< BV >::operator= ( interval_enumerator< BV > &&  ien)
inline

move assignmment operator

Definition at line 122 of file bmintervals.h.

References bm::interval_enumerator< BV >::swap().

◆ operator==()

template<typename BV>
bool bm::interval_enumerator< BV >::operator== ( const interval_enumerator< BV > &  ien) const
inline

Definition at line 138 of file bmintervals.h.

References bm::interval_enumerator< BV >::start().

◆ operator>()

template<typename BV>
bool bm::interval_enumerator< BV >::operator> ( const interval_enumerator< BV > &  ien) const
inline

Definition at line 146 of file bmintervals.h.

References bm::interval_enumerator< BV >::start().

◆ operator>=()

template<typename BV>
bool bm::interval_enumerator< BV >::operator>= ( const interval_enumerator< BV > &  ien) const
inline

◆ start()

template<typename BV >
interval_enumerator< BV >::size_type bm::interval_enumerator< BV >::start ( ) const

◆ swap()

template<typename BV >
void bm::interval_enumerator< BV >::swap ( interval_enumerator< BV > &  ien)

◆ valid()

template<typename BV >
bool bm::interval_enumerator< BV >::valid ( ) const

Returns true if enumerator is valid (false if traversal is done)

Examples:
sample23.cpp, and xsample08.cpp.

Definition at line 568 of file bmintervals.h.

References bm::pair< First, Second >::first, and bm::id_max.

Referenced by bm::interval_enumerator< BV >::advance(), bm::interval_enumerator< BV >::get(), main(), and print_model().


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