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

BitMagic-C++

Public Types | Public Member Functions
bm::bvector< Alloc >::enumerator Class Reference
BitMagic Library » bvector<> container » bvector<> iterators

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

`#include <bm.h>`

Inheritance diagram for bm::bvector< Alloc >::enumerator:
[legend]
Collaboration diagram for bm::bvector< Alloc >::enumerator:
[legend]

## 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. 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) BMNOEXCEPT
| Construct enumerator for bit vector. More...
size_type | operator* () const BMNOEXCEPT
| Get current position (value) More...
size_type | value () const BMNOEXCEPT
| Get current position (value) More...
enumerator & | operator++ () BMNOEXCEPT
| Advance enumerator forward to the next available bit. More...
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. More...
void | go_first () BMNOEXCEPT
| Position enumerator to the first available bit. More...
bool | advance () BMNOEXCEPT
bool | go_up () BMNOEXCEPT
| Advance enumerator to the next available bit. More...
bool | skip_to_rank (size_type rank) BMNOEXCEPT
| Skip to specified relative rank. More...
bool | skip (size_type rank) BMNOEXCEPT
| Skip specified number of bits from enumeration. More...
bool | go_to (size_type pos) BMNOEXCEPT
| go to a specific position in the bit-vector (or next) More...
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. Analog of != 0 comparison for pointers. More...
void | invalidate () BMNOEXCEPT
| Turns iterator into an invalid state. More...
bool | compare_state (const iterator_base &ib) const BMNOEXCEPT
| Compare FSMs for testing purposes. More...

## 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_t * | block_
| 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.

Examples
  bvsample01_64.cpp, bvsetalgebra.cpp, sample5.cpp, sample8.cpp, svsample04.cpp, svsample05.cpp, svsample06.cpp, xsample01.cpp, xsample03.cpp, and xsample04.cpp.

Definition at line 599 of file bm.h.

## Member Typedef Documentation

## ◆ difference_type

template<class Alloc >

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

Definition at line 606 of file bm.h.

## ◆ iterator_category

template<class Alloc >

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

Definition at line 603 of file bm.h.

## ◆ pointer

template<class Alloc >

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

Definition at line 607 of file bm.h.

## ◆ reference

template<class Alloc >

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

Definition at line 608 of file bm.h.

## ◆ value_type

template<class Alloc >

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

Definition at line 605 of file bm.h.

## Constructor & Destructor Documentation

## ◆ enumerator() [1/3]

template<class Alloc >

bm::bvector< Alloc >::enumerator::enumerator | ( |  | ) |
| inline

Definition at line 611 of file bm.h.

## ◆ enumerator() [2/3]

template<class Alloc >

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

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

Definition at line 618 of file bm.h.

References bm::bvector< Alloc >::iterator_base::bv_.

## ◆ enumerator() [3/3]

template<class Alloc >

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

Construct enumerator for bit vector.

Parameters

  bv | bit-vector pointer
  pos | bit position in the vector if position is 0, it finds the next 1 or becomes not valid (en.valid() == false)

Definition at line 630 of file bm.h.

References bm::bvector< Alloc >::iterator_base::bv_, and bm::bvector< Alloc >::enumerator::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 662 of file bm.h.

References bm::bvector< Alloc >::enumerator::go_up().

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

## ◆ go_first()

template<class Alloc >

void bm::bvector< Alloc >::enumerator::go_first

Position enumerator to the first available bit.

Definition at line 6962 of file bm.h.

References bm::bits_in_array, bm::bits_in_block, BM_ASSERT, BM_IS_GAP, FULL_BLOCK_FAKE_ADDR, FULL_BLOCK_REAL_ADDR, FULL_SUB_BLOCK_REAL_ADDR, and bm::set_sub_array_size.

## ◆ go_to()

template<class Alloc >

bool bm::bvector< Alloc >::enumerator::go_to | ( | size_type | pos | ) |

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

Examples
  sample5.cpp.

Definition at line 6870 of file bm.h.

References bm::bvector< Alloc >::iterator_base::block_descr::bit_, bm::bvector< Alloc >::iterator_base::bitblock_descr::bits, bm::bitscan_wave(), BM_ASSERT, BM_IS_GAP, BMGAP_PTR, 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::get_block_coord(), bm::bvector< Alloc >::iterator_base::bitblock_descr::idx, bm::bvector< Alloc >::iterator_base::bitblock_descr::pos, bm::bvector< Alloc >::iterator_base::bitblock_descr::ptr, bm::bvector< Alloc >::iterator_base::dgap_descr::ptr, bm::set_bitscan_wave_size, bm::set_block_mask, bm::set_block_shift, bm::set_block_size, bm::set_word_mask, and bm::set_word_shift.

Referenced by bm::bvector< Alloc >::enumerator::enumerator(), and main().

## ◆ go_up()

template<class Alloc >

bool bm::bvector< Alloc >::enumerator::go_up

Advance enumerator to the next available bit.

Definition at line 6744 of file bm.h.

References bm::bvector< Alloc >::iterator_base::block_descr::bit_, bm::bvector< Alloc >::iterator_base::bitblock_descr::bits, BM_ASSERT, bm::bvector< Alloc >::iterator_base::block_descr::gap_, bm::bvector< Alloc >::iterator_base::dgap_descr::gap_len, bm::gap_max_bits, bm::bvector< Alloc >::iterator_base::bitblock_descr::idx, bm::bvector< Alloc >::iterator_base::bitblock_descr::pos, bm::bvector< Alloc >::iterator_base::bitblock_descr::ptr, bm::bvector< Alloc >::iterator_base::dgap_descr::ptr, and bm::set_bitscan_wave_size.

Referenced by bm::bvector< Alloc >::enumerator::advance(), bm::bvector< Alloc >::enumerator::operator++(), and bm::bvector< Alloc >::counted_enumerator::operator++().

## ◆ operator*()

template<class Alloc >

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

Get current position (value)

Definition at line 638 of file bm.h.

References 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 644 of file bm.h.

References bm::bvector< Alloc >::enumerator::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 649 of file bm.h.

References bm::bvector< Alloc >::enumerator::go_up().

## ◆ skip()

template<class Alloc >

bool bm::bvector< Alloc >::enumerator::skip | ( | size_type | rank | ) |

Skip specified number of bits from enumeration.

Parameters

  rank | - number of ON bits to skip

Returns
  true if skip was successfull and enumerator is valid

Definition at line 6797 of file bm.h.

References bm::bvector< Alloc >::iterator_base::block_descr::bit_, bm::bvector< Alloc >::iterator_base::bitblock_descr::bits, BM_ASSERT, bm::bvector< Alloc >::iterator_base::block_descr::gap_, bm::bvector< Alloc >::iterator_base::dgap_descr::gap_len, bm::gap_max_bits, bm::bvector< Alloc >::iterator_base::bitblock_descr::idx, bm::bvector< Alloc >::iterator_base::bitblock_descr::pos, bm::bvector< Alloc >::iterator_base::bitblock_descr::ptr, bm::bvector< Alloc >::iterator_base::dgap_descr::ptr, bm::bvector< Alloc >::rank(), and bm::set_bitscan_wave_size.

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

## ◆ 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 672 of file bm.h.

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

## ◆ value()

template<class Alloc >

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

Get current position (value)

Definition at line 641 of file bm.h.

References bm::bvector< Alloc >::iterator_base::position_.

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

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

- bm.h