#include <bm.h>
Public Types | |
typedef Alloc | allocator_type |
typedef blocks_manager< Alloc, MS > | blocks_manager_type |
typedef bm::id_t | size_type |
Type used to count bits in the bit vector. | |
typedef bool | const_reference |
enum | optmode { opt_free_0 = 1, opt_free_01 = 2, opt_compress = 3 } |
Optimization mode Every next level means additional checks (better compression vs time). More... | |
Public Member Functions | |
bvector (strategy strat=BM_BIT, const gap_word_t *glevel_len=bm::gap_len_table< true >::_len, size_type bv_size=bm::id_max, const Alloc &alloc=Alloc()) | |
Constructs bvector class. | |
bvector (size_type bv_size, strategy strat=BM_BIT, const gap_word_t *glevel_len=bm::gap_len_table< true >::_len, const Alloc &alloc=Alloc()) | |
Constructs bvector class. | |
bvector (const bvector< Alloc, MS > &bvect) | |
bvector & | operator= (const bvector< Alloc, MS > &bvect) |
reference | operator[] (bm::id_t n) |
bool | operator[] (bm::id_t n) const |
void | operator &= (const bvector< Alloc, MS > &bvect) |
void | operator^= (const bvector< Alloc, MS > &bvect) |
void | operator|= (const bvector< Alloc, MS > &bvect) |
void | operator-= (const bvector< Alloc, MS > &bvect) |
bool | operator< (const bvector< Alloc, MS > &bvect) const |
bool | operator<= (const bvector< Alloc, MS > &bvect) const |
bool | operator> (const bvector< Alloc, MS > &bvect) const |
bool | operator>= (const bvector< Alloc, MS > &bvect) const |
bool | operator== (const bvector< Alloc, MS > &bvect) const |
bool | operator!= (const bvector< Alloc, MS > &bvect) const |
bvector< Alloc, MS > | operator~ () const |
Alloc | get_allocator () const |
bool | set_bit (bm::id_t n, bool val=true) |
Sets bit n. | |
bool | set_bit_and (bm::id_t n, bool val=true) |
Sets bit n using bit AND with the provided value. | |
bool | set_bit_conditional (bm::id_t n, bool val, bool condition) |
Sets bit n only if current value is equal to the condition. | |
bvector< Alloc, MS > & | set (bm::id_t n, bool val=true) |
Sets bit n if val is true, clears bit n if val is false. | |
bvector< Alloc, MS > & | set () |
Sets every bit in this bitset to 1. | |
bvector< Alloc, MS > & | set_range (bm::id_t left, bm::id_t right, bool value=true) |
Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's size. This method DOES NOT resize vector. | |
insert_iterator | inserter () |
void | clear_bit (bm::id_t n) |
Clears bit n. | |
void | clear (bool free_mem=false) |
Clears every bit in the bitvector. | |
bvector< Alloc, MS > & | reset () |
Clears every bit in the bitvector. | |
bm::id_t | count () const |
Returns count of bits which are 1. | |
size_type | capacity () const |
Returns bvector's capacity (number of bits it can store). | |
size_type | size () const |
return current size of the vector (bits) | |
void | resize (size_type new_size) |
Change size of the bvector. | |
unsigned | count_blocks (unsigned *arr) const |
Computes bitcount values for all bvector blocks. | |
bm::id_t | count_range (bm::id_t left, bm::id_t right, unsigned *block_count_arr=0) const |
Returns count of 1 bits in the given diapason. | |
bm::id_t | recalc_count () |
void | forget_count () |
bvector< Alloc, MS > & | invert () |
Inverts all bits. | |
bool | get_bit (bm::id_t n) const |
returns true if bit n is set and false is bit n is 0. | |
bool | test (bm::id_t n) const |
returns true if bit n is set and false is bit n is 0. | |
bool | any () const |
Returns true if any bits in this bitset are set, and otherwise returns false. | |
bool | none () const |
Returns true if no bits are set, otherwise returns false. | |
bvector< Alloc, MS > & | flip (bm::id_t n) |
Flips bit n. | |
bvector< Alloc, MS > & | flip () |
Flips all bits. | |
void | swap (bvector< Alloc, MS > &bv) |
Exchanges content of bv and this bitvector. | |
bm::id_t | get_first () const |
Gets number of first bit which is ON. | |
bm::id_t | get_next (bm::id_t prev) const |
Finds the number of the next bit ON. | |
bm::id_t | extract_next (bm::id_t prev) |
Finds the number of the next bit ON and sets it to 0. | |
void | calc_stat (struct statistics *st) const |
Calculates bitvector statistics. | |
bm::bvector< Alloc, MS > & | bit_or (const bm::bvector< Alloc, MS > &vect) |
Logical OR operation. | |
bm::bvector< Alloc, MS > & | bit_and (const bm::bvector< Alloc, MS > &vect) |
Logical AND operation. | |
bm::bvector< Alloc, MS > & | bit_xor (const bm::bvector< Alloc, MS > &vect) |
Logical XOR operation. | |
bm::bvector< Alloc, MS > & | bit_sub (const bm::bvector< Alloc, MS > &vect) |
Logical SUB operation. | |
void | set_new_blocks_strat (strategy strat) |
Sets new blocks allocation strategy. | |
strategy | get_new_blocks_strat () const |
Returns blocks allocation strategy. | |
void | stat (unsigned blocks=0) const |
void | optimize (bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0) |
Optimize memory bitvector's memory allocation. | |
void | optimize_gap_size () |
Optimize sizes of GAP blocks. | |
void | set_gap_levels (const gap_word_t *glevel_len) |
Sets new GAP lengths table. All GAP blocks will be reallocated to match the new scheme. | |
int | compare (const bvector< Alloc, MS > &bvect) const |
Lexicographical comparison with a bitvector. | |
bm::word_t * | allocate_tempblock () const |
Allocates temporary block of memory. | |
void | free_tempblock (bm::word_t *block) const |
Frees temporary block of memory. | |
enumerator | first () const |
Returns enumerator pointing on the first non-zero bit. | |
enumerator | end () const |
Returns enumerator pointing on the next bit after the last. | |
const bm::word_t * | get_block (unsigned nb) const |
void | combine_operation (const bm::bvector< Alloc, MS > &bvect, bm::operation opcode) |
void | combine_operation_with_block (unsigned nb, const bm::word_t *arg_blk, int arg_gap, bm::operation opcode) |
const blocks_manager_type & | get_blocks_manager () const |
blocks_manager_type & | get_blocks_manager () |
Friends | |
class | iterator_base |
class | enumerator |
Data Structures | |
class | counted_enumerator |
Constant input iterator designed to enumerate "ON" bits counted_enumerator keeps bitcount, ie number of ON bits starting from the position 0 in the bit string up to the currently enumerated bit. More... | |
class | enumerator |
Constant input iterator designed to enumerate "ON" bits. More... | |
class | insert_iterator |
Output iterator iterator designed to set "ON" bits based on input sequence of integers (bit indeces). More... | |
class | iterator_base |
Base class for all iterators. More... | |
class | reference |
Class reference implements an object for bit assignment. Since C++ does not provide with build-in bit type supporting l-value operations we have to emulate it. More... | |
struct | statistics |
Statistical information about bitset's memory allocation details. More... |
sample1.cpp, sample2.cpp, sample3.cpp, sample4.cpp, sample5.cpp, sample6.cpp, sample7.cpp, sample8.cpp, and sample9.cpp.
Definition at line 112 of file bm.h.
|
|
|
|
|
|
|
Type used to count bits in the bit vector.
|
|
Optimization mode Every next level means additional checks (better compression vs time).
|
|
Constructs bvector class.
|
|
Constructs bvector class.
|
|
|
|
Allocates temporary block of memory. Temp block can be passed to bvector functions requiring some temp memory for their operation. (like serialize)
|
|
Returns true if any bits in this bitset are set, and otherwise returns false.
Definition at line 1163 of file bm.h. References bm::for_each_nzblock_if(). Referenced by bm::bvector< Alloc, MS >::none(). |
|
Logical AND operation.
Definition at line 1283 of file bm.h. References bm::BM_AND, BMCOUNT_VALID, and bm::bvector< Alloc, MS >::combine_operation(). Referenced by bm::operator &(), and bm::bvector< Alloc, MS >::operator &=(). |
|
Logical OR operation.
Definition at line 1272 of file bm.h. References bm::BM_OR, BMCOUNT_VALID, and bm::bvector< Alloc, MS >::combine_operation(). Referenced by bm::bvector< Alloc, MS >::operator=(), bm::operator|(), and bm::bvector< Alloc, MS >::operator|=(). |
|
Logical SUB operation.
Definition at line 1305 of file bm.h. References bm::BM_SUB, BMCOUNT_VALID, and bm::bvector< Alloc, MS >::combine_operation(). Referenced by bm::operator-(), and bm::bvector< Alloc, MS >::operator-=(). |
|
Logical XOR operation.
Definition at line 1294 of file bm.h. References bm::BM_XOR, BMCOUNT_VALID, and bm::bvector< Alloc, MS >::combine_operation(). Referenced by bm::operator^(), and bm::bvector< Alloc, MS >::operator^=(). |
|
Calculates bitvector statistics.
Referenced by CreateSets(), FillSets(), bm::bvector< Alloc, MS >::optimize_gap_size(), and serialize_bvector(). |
|
Returns bvector's capacity (number of bits it can store).
|
|
Clears every bit in the bitvector.
Definition at line 1044 of file bm.h. References BMCOUNT_SET. Referenced by main(), bm::bvector< Alloc, MS >::operator=(), and bm::bvector< Alloc, MS >::reset(). |
|
Clears bit n.
Definition at line 1032 of file bm.h. References bm::bvector< Alloc, MS >::set(). |
|
|
Definition at line 1481 of file bm.h. References BM_IS_GAP, and bm::bvector< Alloc, MS >::get_block(). Referenced by bm::bvector< Alloc, MS >::combine_operation(). |
|
Lexicographical comparison with a bitvector. Function compares current bitvector with the provided argument bit by bit and returns -1 if our bitvector less than the argument, 1 - greater, 0 - equal. Definition at line 1909 of file bm.h. References bm::bit_is_all_zero(), bm::bitcmp(), bm::bvector< Alloc, MS >::blockman_, BM_IS_GAP, BMGAP_PTR, bm::gap_convert_to_bitset(), bm::gap_is_all_zero(), and bm::gapcmp(). Referenced by main(), bm::bvector< Alloc, MS >::operator!=(), bm::bvector< Alloc, MS >::operator<(), bm::bvector< Alloc, MS >::operator<=(), bm::bvector< Alloc, MS >::operator==(), bm::bvector< Alloc, MS >::operator>(), and bm::bvector< Alloc, MS >::operator>=(). |
|
Returns count of bits which are 1.
Definition at line 1638 of file bm.h. References BMCOUNT_SET, and bm::for_each_nzblock(). Referenced by bm::bvector< Alloc, MS >::count_range(), main(), OrSets(), bm::bvector< Alloc, MS >::recalc_count(), serialize_bvector(), and bm::bvector< Alloc, MS >::stat(). |
|
Computes bitcount values for all bvector blocks.
Definition at line 1095 of file bm.h. References bm::for_each_nzblock(). |
|
Returns count of 1 bits in the given diapason.
Definition at line 1678 of file bm.h. References bm::bit_block_calc_count_range(), BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bm::bvector< Alloc, MS >::count(), bm::gap_bit_count_range(), and bm::bvector< Alloc, MS >::get_block(). |
|
Returns enumerator pointing on the next bit after the last.
Definition at line 1437 of file bm.h. Referenced by EnumerateSets(), and main(). |
|
Finds the number of the next bit ON and sets it to 0.
|
|
Returns enumerator pointing on the first non-zero bit.
Definition at line 1427 of file bm.h. Referenced by EnumerateSets(), and main(). |
|
Flips all bits.
Definition at line 1201 of file bm.h. References bm::bvector< Alloc, MS >::invert(). |
|
Flips bit n.
Definition at line 1191 of file bm.h. References bm::bvector< Alloc, MS >::get_bit(), and bm::bvector< Alloc, MS >::set(). |
|
Disables count cache. Next call to count() or recalc_count() restores count caching.
Definition at line 1131 of file bm.h. References BMCOUNT_VALID. |
|
Frees temporary block of memory.
|
|
|
|
returns true if bit n is set and false is bit n is 0.
Definition at line 1796 of file bm.h. References BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bm::gap_test(), and bm::bvector< Alloc, MS >::get_block(). Referenced by bm::bvector< Alloc, MS >::flip(), bm::bvector< Alloc, MS >::operator[](), and bm::bvector< Alloc, MS >::test(). |
|
Definition at line 1444 of file bm.h. Referenced by bm::bvector< Alloc, MS >::combine_operation(), bm::bvector< Alloc, MS >::combine_operation_with_block(), bm::bvector< Alloc, MS >::count_range(), bm::bvector< Alloc, MS >::get_bit(), and bm::bvector< Alloc, MS >::stat(). |
|
|
|
|
|
Gets number of first bit which is ON.
Definition at line 1228 of file bm.h. Referenced by main(). |
|
Returns blocks allocation strategy.
|
|
Finds the number of the next bit ON.
Definition at line 1237 of file bm.h. Referenced by main(). |
|
Function erturns insert iterator for this bitvector Definition at line 1022 of file bm.h. Referenced by main(). |
|
Inverts all bits.
Definition at line 1772 of file bm.h. References BM_SET_MMX_GUARD, BMCOUNT_VALID, and bm::for_each_block(). Referenced by bm::bvector< Alloc, MS >::flip(). |
|
Returns true if no bits are set, otherwise returns false.
Definition at line 1182 of file bm.h. References bm::bvector< Alloc, MS >::any(). |
|
Definition at line 879 of file bm.h. References bm::bvector< Alloc, MS >::bit_and(). |
|
Definition at line 924 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 894 of file bm.h. References bm::bvector< Alloc, MS >::bit_sub(). |
|
Definition at line 899 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 904 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 858 of file bm.h. References bm::bvector< Alloc, MS >::bit_or(), bm::bvector< Alloc, MS >::clear(), and bm::bvector< Alloc, MS >::resize(). |
|
Definition at line 919 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 909 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 914 of file bm.h. References bm::bvector< Alloc, MS >::compare(). |
|
Definition at line 873 of file bm.h. References BM_ASSERT, and bm::bvector< Alloc, MS >::get_bit(). |
|
Definition at line 866 of file bm.h. References BM_ASSERT. |
|
Definition at line 884 of file bm.h. References bm::bvector< Alloc, MS >::bit_xor(). |
|
Definition at line 889 of file bm.h. References bm::bvector< Alloc, MS >::bit_or(). |
|
|
|
Optimize memory bitvector's memory allocation. Function analyze all blocks in the bitvector, compresses blocks with a regular structure, frees some memory. This function is recommended after a bulk modification of the bitvector using set_bit, clear_bit or logical operations. Optionally function can calculate vector post optimization statistics
Definition at line 1830 of file bm.h. References bm::for_each_nzblock(), and bm::bvector< Alloc, MS >::stat(). Referenced by main(), and serialize_bvector(). |
|
Optimize sizes of GAP blocks. This method runs an analysis to find optimal GAP levels for the specific vector. Current GAP compression algorithm uses several fixed GAP sizes. By default bvector uses some reasonable preset. Definition at line 1872 of file bm.h. References bm::bvector< Alloc, MS >::calc_stat(), bm::gap_levels, bm::improve_gap_levels(), and bm::bvector< Alloc, MS >::set_gap_levels(). |
|
Definition at line 1118 of file bm.h. References BMCOUNT_VALID, and bm::bvector< Alloc, MS >::count(). |
|
Clears every bit in the bitvector.
Definition at line 1054 of file bm.h. References bm::bvector< Alloc, MS >::clear(). |
|
Change size of the bvector.
Definition at line 1660 of file bm.h. References bm::bvector< Alloc, MS >::set_range(). Referenced by main(), and bm::bvector< Alloc, MS >::operator=(). |
|
Sets every bit in this bitset to 1.
Definition at line 997 of file bm.h. References BMCOUNT_VALID, and bm::bvector< Alloc, MS >::set_range(). Referenced by bm::bvector< Alloc, MS >::clear_bit(), and bm::bvector< Alloc, MS >::flip(). |
|
Sets bit n if val is true, clears bit n if val is false.
Definition at line 985 of file bm.h. References bm::bvector< Alloc, MS >::set_bit(). Referenced by main(). |
|
Sets bit n.
Definition at line 946 of file bm.h. References BM_ASSERT. Referenced by bm::bvector< Alloc, MS >::set(). |
|
Sets bit n using bit AND with the provided value.
Definition at line 958 of file bm.h. References BM_ASSERT. |
|
Sets bit n only if current value is equal to the condition.
Definition at line 971 of file bm.h. References BM_ASSERT. |
|
Sets new GAP lengths table. All GAP blocks will be reallocated to match the new scheme.
Definition at line 1893 of file bm.h. References bm::for_each_nzblock(), and bm::bvector< Alloc, MS >::set_gap_levels(). Referenced by bm::bvector< Alloc, MS >::optimize_gap_size(), and bm::bvector< Alloc, MS >::set_gap_levels(). |
|
Sets new blocks allocation strategy.
Definition at line 1318 of file bm.h. Referenced by main(). |
|
Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's size. This method DOES NOT resize vector.
Definition at line 1615 of file bm.h. References BM_ASSERT, BM_SET_MMX_GUARD, and BMCOUNT_VALID. Referenced by bm::bvector< Alloc, MS >::combine_operation(), bm::bvector< Alloc, MS >::resize(), and bm::bvector< Alloc, MS >::set(). |
|
return current size of the vector (bits)
|
|
Definition at line 2351 of file bm.h. References bm::bit_block_calc_count(), BMGAP_PTR, bm::bvector< Alloc, MS >::count(), bm::gap_bit_count(), bm::gap_control_sum(), bm::gap_length(), bm::gap_level(), bm::bvector< Alloc, MS >::get_block(), and IS_FULL_BLOCK. Referenced by bm::bvector< Alloc, MS >::optimize(). |
|
Exchanges content of bv and this bitvector.
Definition at line 1208 of file bm.h. References BMCOUNT_VALID, and bm::xor_swap(). |
|
returns true if bit n is set and false is bit n is 0.
Definition at line 1154 of file bm.h. References bm::bvector< Alloc, MS >::get_bit(). |
|
|
|
|