#include <iostream>
#include <random>
#include <memory>
using namespace std;
static
{
{
for (j = 0; j < 65535*8; i += 10, j++)
{
}
break;
for (j = 0; j < 65535; i += 120, j++)
{
unsigned len = rand() % 64;
i += len;
break;
}
}
std::cout <<
"Bit-vector statistics: GAP (compressed blocks)=" << st.
gap_blocks
<<
", BIT (uncompressed blocks)=" << st.
bit_blocks
<< std::endl << std::endl;
}
static
{
{
m+=cnt*cnt;
}
return m;
}
static
{
{
{
}
}
std::cout << "Count test finished." << cnt << "\r";
}
static
{
{
{
if (from > to)
swap(from, to);
}
}
std::cout << "Count range test finished." << cnt << "\r";
}
static
{
{
cnt = 0;
{
if (from > to)
swap(from, to);
}
}
std::cout << "Count range with blocks test finished." << cnt << "\r";
}
static
{
{
{
}
}
std::cout << "Count to with blocks test finished." << cnt << "\r";
}
static
{
{
{
if (from > to)
swap(from, to);
cnt += cnt_r;
}
}
std::cout << "Count range via count_to test finished." << cnt << "\r";
}
static
{
{
{
if (from > to)
swap(from, to);
mask_bv.set_range(from, to, true);
mask_bv.clear(true);
}
}
std::cout << "count AND finished." << cnt << "\r";
}
static
{
{
{
{
if (*en > to)
break;
}
}
}
std::cout << "counted_enumerator finished." << cnt << "\r";
}
{
try
{
std::cout << s << "\r";
std::cout << " "
<< std::endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Algorithms for bvector<> (main include)
Timing utilities for benchmarking (internal)
pre-processor un-defines to avoid global space pollution (internal)
Constant iterator designed to enumerate "ON" bits counted_enumerator keeps bitcount,...
size_type count() const BMNOEXCEPT
Number of bits ON starting from the .
bool valid() const BMNOEXCEPT
Checks if iterator is still valid.
Bitvector Bit-vector container with runtime compression of bits.
size_type count() const BMNOEXCEPT
population count (count of ON bits)
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
bvector_size_type size_type
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
size_type count_range(size_type left, size_type right, const rs_index_type &rs_idx) const BMNOEXCEPT
Returns count of 1 bits in the given range [left..right] Uses rank-select index to accelerate the sea...
bvector< Alloc > & set_range(size_type left, size_type right, bool value=true)
Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's siz...
rs_index< allocator_type > rs_index_type
size_type count_to(size_type n, const rs_index_type &rs_idx) const BMNOEXCEPT
Returns count of 1 bits (population) in [0..right] range.
void build_rs_index(rs_index_type *rs_idx, bvector< Alloc > *bv_blocks=0) const
compute running total of all blocks in bit vector (rank-select index)
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const BMNOEXCEPT
Calculates bitvector statistics.
Utility class to collect performance measurements and statistics.
std::map< std::string, statistics > duration_map_type
test name to duration map
static void print_duration_map(TOut &tout, const duration_map_type &dmap, format fmt=ct_time)
@ BM_GAP
GAP compression is ON.
BV::size_type count_and(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of AND operation of two bitsets.
const unsigned benchmark_count
static void bv_count_range(const bm::bvector<> &bv)
count_range() test
static bm::bvector ::size_type pre_heat(const bm::bvector<> &bv)
"pre-heat" CPU to minimize dynamic overclocking effects
static void bv_count_to_range_acc(const bm::bvector<> &bv)
count_range implemented via two count_to() calls using pre-calculated rank-select index
std::random_device rand_dev
static void bv_count_range_acc(const bm::bvector<> &bv)
count_range() test using pre-calculated blocks bit count
std::uniform_int_distribution rand_dis(1, int(vector_max))
bm::chrono_taker ::duration_map_type timing_map
std::mt19937 gen(rand_dev())
static void bv_count_test(const bm::bvector<> &bv)
simple population count for the whole vector
static void generate_bvector(bm::bvector<> &bv)
generate pseudo-random bit-vector, mix of blocks
static void bv_count_and(const bm::bvector<> &bv)
count_range implemented via bm::count_and
static void bv_count_to_acc(const bm::bvector<> &bv)
count_to() test using pre-calculated rank-select index
static void bv_counted_enumerator(const bm::bvector<> &bv)
count_to implemented via bm::bvector<>::counted_enumerator
size_t gap_blocks
Number of GAP blocks.
size_t bit_blocks
Number of bit blocks.
Statistical information about bitset's memory allocation details.