Exmaple demonstrates using bitvectors with different initial block allocation strategy.
Exmaple demonstrates using bitvectors with different initial block allocation strategy.Bitvector 1 (bv1) by default working without RLE compression option (best performance, maximum memory consumption). Bitvector 2 (bv2) will be working in compression mode and use less memory.
- See also
- bm::bvector<>::set_new_blocks_strat()
For more information please visit: http://bmagic.sourceforge.net
#include <stdlib.h>
#include <iostream>
using namespace std;
static
{
{
if (rand() % 2500)
{
}
}
}
static
{
bm::bvector<>::statistics st;
cout <<
"Bits count:" << bv.
count() << endl;
cout << "Bit blocks:" << st.bit_blocks << endl;
cout << "GAP blocks:" << st.gap_blocks << endl;
cout << "Memory used:"<< st.memory_used << endl;
cout << "Max.serialize mem.:" << st.max_serialize_mem << endl << endl;;
}
{
try
{
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
size_type count() const BMNOEXCEPT
population cout (count of ON bits)
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
void set_new_blocks_strat(strategy strat)
Sets new blocks allocation strategy.
bool set_bit(size_type n, bool val=true)
Sets bit n.
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const BMNOEXCEPT
Calculates bitvector statistics.
@ BM_GAP
GAP compression is ON.
static void print_statistics(const bm::bvector<> &bv)
static void fill_bvector(bm::bvector<> *bv1, bm::bvector<> *bv2)