bm::interval_enumerator< BV > Class Template Reference
BitMagic Library » bvector<> container » Algorithms for bit intervals

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

`#include <bmintervals.h>`

Inheritance diagram for bm::interval_enumerator< BV >:
[legend]

## 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_type > | buffer_type
typedef bm::pair< size_type, size_type > | pair_type

## Public Member Functions

Construction and assignment
| interval_enumerator ()
| interval_enumerator (const BV &bv)
| Construct enumerator for the bit-vector.
| interval_enumerator (const BV &bv, size_type start_pos, bool extend_start)
| Construct enumerator for the specified position.
| interval_enumerator (const interval_enumerator< BV > &ien)
| Copy constructor.
interval_enumerator & | operator= (const interval_enumerator< BV > &ien)
| Assignment operator.
| interval_enumerator (interval_enumerator< BV > &&ien) BMNOEXCEPT
| move-ctor
interval_enumerator< BV > & | operator= (interval_enumerator< BV > &&ien) BMNOEXCEPT
| move assignmment operator
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
size_type | start () const BMNOEXCEPT
| Return interval start/left as bit-vector coordinate 011110 [left..right].
size_type | end () const BMNOEXCEPT
| Return interval end/right as bit-vector coordinate 011110 [left..right].
const pair_type & | operator* () const BMNOEXCEPT
const pair_type & | get () const BMNOEXCEPT
| Get interval pair.
bool | valid () const BMNOEXCEPT
| Returns true if enumerator is valid (false if traversal is done).

## enumerator positioning

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
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.
bool | advance ()
interval_enumerator< BV > & | operator++ () BMNOEXCEPT
| Advance enumerator forward to the next available bit.
interval_enumerator< BV > | operator++ (int) BMNOEXCEPT
| Advance enumerator forward to the next available bit.
void | swap (interval_enumerator< BV > &ien) BMNOEXCEPT
| swap enumerator with another one
bool | go_to_impl (size_type pos, bool extend_start)
void | invalidate () BMNOEXCEPT
| Turn FSM into invalid state (out of range).

## 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, svsample07a.cpp, and xsample08.cpp.

Definition at line 52 of file bmintervals.h.

## Member Typedef Documentation

## allocator_type

template<typename BV>

typedef bvector_type::allocator_type bm::interval_enumerator< BV >::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.

Referenced by swap().

## 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.

## 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.

## 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.

## 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.

## Member Function Documentation

## advance()

template<typename BV>

bool bm::interval_enumerator< BV >::advance | ( |  | ) |

Advance to the next interval

Returns
  true if interval is available

See also
  valid

Definition at line 717 of file bmintervals.h.

References BM_ASSERT, bm::find_interval_end(), bm::gap_max_bits, go_to_impl(), bm::id_max, invalidate(), bm::set_block_shift, and valid().

Referenced by main(), bm::interval_enumerator< bm::bvector<> >::operator++(), bm::interval_enumerator< bm::bvector<> >::operator++(), and print_model().

## 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].

Definition at line 560 of file bmintervals.h.

References BMNOEXCEPT.

Referenced by main(), and print_model().

## get()

template<typename BV>

const pair_type & bm::interval_enumerator< BV >::get | ( |  | ) | const

inline

Get interval pair.

Definition at line 161 of file bmintervals.h.

Referenced by main().

## 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

Definition at line 584 of file bmintervals.h.

References go_to_impl().

Referenced by main().

## go_to_impl()

template<typename BV>

bool bm::interval_enumerator< BV >::go_to_impl | ( | size_type | pos,
|  | bool | extend_start )

protected

Definition at line 592 of file bmintervals.h.

References bm::bit_to_gap(), BM_ASSERT, BM_IS_GAP, BMGAP_PTR, BMRESTRICT, bm::find_interval_end(), bm::find_interval_start(), FULL_BLOCK_FAKE_ADDR, bm::gap_bfind(), bm::gap_max_bits, bm::get_block_coord(), bm::id_max, invalidate(), bm::set_block_mask, and bm::set_block_shift.

Referenced by advance(), go_to(), bm::interval_enumerator< bm::bvector<> >::interval_enumerator(), bm::interval_enumerator< bm::bvector<> >::interval_enumerator(), bm::interval_enumerator< bm::bvector<> >::interval_enumerator(), and bm::interval_enumerator< bm::bvector<> >::operator=().

## 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 BMNOEXCEPT, and bm::id_max.

Referenced by advance(), and 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## operator>=()

template<typename BV>

bool bm::interval_enumerator< BV >::operator>= | ( | const interval_enumerator< BV > & | ien | ) | const

inline

Definition at line 148 of file bmintervals.h.

## start()

template<typename BV>

interval_enumerator< BV >::size_type bm::interval_enumerator< BV >::start | ( |  | ) | const

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

Definition at line 551 of file bmintervals.h.

References BMNOEXCEPT.

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

## swap()

template<typename BV>

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

swap enumerator with another one

Definition at line 757 of file bmintervals.h.

References BMNOEXCEPT, interval_enumerator(), and bm::xor_swap().

Referenced by bm::interval_enumerator< bm::bvector<> >::interval_enumerator(), and bm::interval_enumerator< bm::bvector<> >::operator=().

## valid()

template<typename BV>

bool bm::interval_enumerator< BV >::valid | ( |  | ) | const

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

Definition at line 568 of file bmintervals.h.

References BMNOEXCEPT, and bm::id_max.

Referenced by advance(), main(), and print_model().

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

- bmintervals.h