BitMagicC++Library
Modules | Data Structures | Functions
bvector<> algorithms
Collaboration diagram for bvector<> algorithms:

Modules

 Binary-distance metrics
 

Data Structures

class  bm::random_subset< BV >
 

Functions

template<class BV , class Func >
void bm::for_each_bit (const BV &bv, Func &bit_functor)
 bit-vector visitor scanner to traverse each 1 bit using C++ visitor More...
 
template<class BV >
void bm::visit_each_bit (const BV &bv, void *handle_ptr, bit_visitor_callback_type callback_ptr)
 bit-vector visitor scanner to traverse each 1 bit using C callback More...
 
template<class BV , class It >
void bm::combine_or (BV &bv, It first, It last)
 OR Combine bitvector and the iterable sequence. More...
 
template<class BV , class It >
void bm::combine_xor (BV &bv, It first, It last)
 XOR Combine bitvector and the iterable sequence. More...
 
template<class BV , class It >
void bm::combine_sub (BV &bv, It first, It last)
 SUB Combine bitvector and the iterable sequence. More...
 
template<class BV , class It >
void bm::combine_and_sorted (BV &bv, It first, It last)
 AND Combine bitvector and the iterable sequence. More...
 
template<class BV , class It >
void bm::combine_and (BV &bv, It first, It last)
 AND Combine bitvector and the iterable sequence. More...
 
template<class BV >
bm::id_t bm::count_intervals (const BV &bv)
 Compute number of bit intervals (GAPs) in the bitvector. More...
 
template<class BV , class It >
void bm::export_array (BV &bv, It first, It last)
 Export bitset from an array of binary data representing the bit vector. More...
 

Detailed Description

Set algebra algorithms using bit-vectors, arrays. Binary metrics and distances. Random sub-sets.

Function Documentation

◆ combine_and()

template<class BV , class It >
void bm::combine_and ( BV &  bv,
It  first,
It  last 
)

AND Combine bitvector and the iterable sequence.

Algorithm combines bvector with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence
See also
combine_and_sorted
Examples:
sample7.cpp.

Definition at line 1434 of file bmalgo_impl.h.

References bm::combine_or().

Referenced by main().

◆ combine_and_sorted()

template<class BV , class It >
void bm::combine_and_sorted ( BV &  bv,
It  first,
It  last 
)

AND Combine bitvector and the iterable sequence.

Algorithm combines bvector with sorted sequence of integers (represents another set).

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence
Examples:
sample7.cpp.

Definition at line 1402 of file bmalgo_impl.h.

References BM_ASSERT.

Referenced by main().

◆ combine_or()

template<class BV , class It >
void bm::combine_or ( BV &  bv,
It  first,
It  last 
)

OR Combine bitvector and the iterable sequence.

Algorithm combines bvector with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence
Examples:
sample12.cpp, sample7.cpp, and xsample01.cpp.

Definition at line 1148 of file bmalgo_impl.h.

References bm::block_range_scan(), BM_ASSERT, BMGAP_PTR, bm::gap_limit(), bm::gap_set_value(), bm::id_max, bm::set_block_mask, bm::set_block_shift, bm::set_word_mask, and bm::set_word_shift.

Referenced by bm::combine_and(), combine_or_test(), bm::operation_deserializer< BV >::deserialize(), bm::sparse_vector< unsigned, bm::bvector<> >::import(), main(), speed_test_sv_index(), and speed_test_vect_index().

◆ combine_sub()

template<class BV , class It >
void bm::combine_sub ( BV &  bv,
It  first,
It  last 
)

SUB Combine bitvector and the iterable sequence.

Algorithm combines bvector with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence
Examples:
sample7.cpp.

Definition at line 1317 of file bmalgo_impl.h.

References bm::block_range_scan(), BM_ASSERT, BMGAP_PTR, bm::gap_limit(), bm::gap_set_value(), bm::gap_test_unr(), bm::id_max, bm::set_block_mask, bm::set_block_shift, bm::set_word_mask, and bm::set_word_shift.

Referenced by bm::operation_deserializer< BV >::deserialize(), and main().

◆ combine_xor()

template<class BV , class It >
void bm::combine_xor ( BV &  bv,
It  first,
It  last 
)

XOR Combine bitvector and the iterable sequence.

Algorithm combines bvector with sequence of integers (represents another set). When the agrument set is sorted this method can give serious increase in performance.

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence

Definition at line 1230 of file bmalgo_impl.h.

References bm::block_range_scan(), BM_ASSERT, BMGAP_PTR, bm::gap_limit(), bm::gap_set_value(), bm::gap_test_unr(), bm::id_max, bm::set_block_mask, bm::set_block_shift, bm::set_word_mask, and bm::set_word_shift.

◆ count_intervals()

template<class BV >
bm::id_t bm::count_intervals ( const BV &  bv)

Compute number of bit intervals (GAPs) in the bitvector.

Algorithm traverses bit vector and count number of uninterrupted intervals of 1s and 0s.

For example: 
  empty vector   - 1 interval
  00001111100000 - gives us 3 intervals
  10001111100000 - 4 intervals
  00000000000000 - 1 interval
  11111111111111 - 1 interval
Returns
Number of intervals

Definition at line 1458 of file bmalgo_impl.h.

References bm::for_each_block().

◆ export_array()

template<class BV , class It >
void bm::export_array ( BV &  bv,
It  first,
It  last 
)

Export bitset from an array of binary data representing the bit vector.

Input array can be array of ints, chars or other native C types. Method works with iterators, which makes it compatible with STL containers and C arrays

Parameters
bv- destination bitvector
first- first element of the iterated sequence
last- last element of the iterated sequence

Definition at line 1487 of file bmalgo_impl.h.

References BM_ASSERT, bm::BM_BIT, BMGAP_PTR, bm::set_block_size, and bm::set_total_blocks.

◆ for_each_bit()

template<class BV , class Func >
void bm::for_each_bit ( const BV &  bv,
Func &  bit_functor 
)

bit-vector visitor scanner to traverse each 1 bit using C++ visitor

Parameters
bv- bit vector to scan
bit_functor(should support add_bits() and add_range() methods

Definition at line 41 of file bmalgo.h.

References bm::bits_in_block, BLOCK_ADDR_SAN, BM_IS_GAP, BMGAP_PTR, bm::for_each_bit_blk(), bm::for_each_gap_blk(), and bm::set_array_size.

Referenced by bm::sparse_vector< unsigned, bm::bvector<> >::extract(), and bm::visit_each_bit().

◆ visit_each_bit()

template<class BV >
void bm::visit_each_bit ( const BV &  bv,
void *  handle_ptr,
bit_visitor_callback_type  callback_ptr 
)

bit-vector visitor scanner to traverse each 1 bit using C callback

Parameters
bv- bit vector to scan
handle_ptr- handle to private memory used by callback
callback_ptr- callback function
See also
bit_visitor_callback_type

Definition at line 95 of file bmalgo.h.

References bm::for_each_bit().