BitMagic-C++
Algorithms for bit intervals

Algorithms and iterators for bit ranges and intervals. More...

Collaboration diagram for Algorithms for bit intervals: ## Data Structures

class  bm::interval_enumerator< BV >
forward iterator class to traverse bit-vector as ranges More...

## Functions

template<class BV >
bool bm::is_interval (const BV &bv, typename BV::size_type left, typename BV::size_type right) BMNOEXCEPT
Returns true if range is all 1s flanked with 0s Function performs the test on a closed range [left, right] true interval is all 1s AND test(left-1)==false AND test(right+1)==false Examples: 01110 [1,3] - true 11110 [0,3] - true 11110 [1,3] - false. More...

template<class BV >
bool bm::find_interval_start (const BV &bv, typename BV::size_type from, typename BV::size_type &pos) BMNOEXCEPT
Reverse find index of first 1 bit gap (01110) starting from position Reverse scan for the first 1 in a block of continious 1s. Method employs closed interval semantics: 0[pos..from]. More...

template<typename BV >
bool bm::find_interval_end (const BV &bv, typename BV::size_type from, typename BV::size_type &pos) BMNOEXCEPT
Reverse find index of first 1 bit gap (01110) starting from position Reverse scan for the first 1 in a block of continious 1s. Method employs closed interval semantics: 0[pos..from]. More...

## Detailed Description

Algorithms and iterators for bit ranges and intervals.

## ◆ find_interval_end()

template<typename BV >
 bool bm::find_interval_end ( const BV & bv, typename BV::size_type from, typename BV::size_type & pos )

Reverse find index of first 1 bit gap (01110) starting from position Reverse scan for the first 1 in a block of continious 1s. Method employs closed interval semantics: 0[pos..from].

Parameters
 bv - bit-vector for search from - position to start reverse search from pos - [out] index of the found first 1 bit in a gap of bits
Returns
true if search returned result, false if not found (start point is zero)
is_interval, find_interval_end
Examples:
sample22.cpp, and xsample08.cpp.

Definition at line 438 of file bmintervals.h.

## ◆ find_interval_start()

template<class BV >
 bool bm::find_interval_start ( const BV & bv, typename BV::size_type from, typename BV::size_type & pos )

Reverse find index of first 1 bit gap (01110) starting from position Reverse scan for the first 1 in a block of continious 1s. Method employs closed interval semantics: 0[pos..from].

Parameters
 bv - bit-vector for search from - position to start reverse search from pos - [out] index of the found first 1 bit in a gap of bits
Returns
true if search returned result, false if not found (start point is zero)
is_interval, find_interval_end
Examples:
sample22.cpp, and xsample08.cpp.

Definition at line 315 of file bmintervals.h.

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

## ◆ is_interval()

template<class BV >
 bool bm::is_interval ( const BV & bv, typename BV::size_type left, typename BV::size_type right )

Returns true if range is all 1s flanked with 0s Function performs the test on a closed range [left, right] true interval is all 1s AND test(left-1)==false AND test(right+1)==false Examples: 01110 [1,3] - true 11110 [0,3] - true 11110 [1,3] - false.

Parameters
 bv - bit-vector for check left - index of first bit start checking right - index of last bit
Returns
true/false