Exmaple demonstrates bitvector serialization/deserialization.For more information please visit: http://bmagic.sourceforge.net
#include <stdlib.h>
#include <iostream>
using namespace std;
static
{
{
if (rand() % 2500)
{
}
}
}
static
{
cout <<
"Bits count:" << bv.
count() << endl;
}
static
{
cout <<
"Bits count:" << bv.
count() << endl;
cout << "Serialized size:" << len << endl << endl;
return buf;
}
{
unsigned char* buf1 = 0;
unsigned char* buf2 = 0;
try
{
{
buf2 = sbuf.data();
auto sz = sbuf.size();
cout << "BV2 Serialized size:" << sz << endl;
}
{
if (cmp != 0)
{
std::cerr << "Error: bug in serialization" << std::endl;
}
cout << "BV_C Serialized size:" << sbuf2.size() << endl;
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
delete [] buf1;
return 1;
}
delete [] buf1;
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Serialization / compression of bvector<>. Set theoretical operations on compressed BLOBs.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bm::bvector< Alloc > & bit_or(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand OR : this := bv1 OR bv2
size_type count() const BMNOEXCEPT
population count (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.
int compare(const bvector< Alloc > &bvect) const BMNOEXCEPT
Lexicographical comparison with a bitvector.
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const BMNOEXCEPT
Calculates bitvector statistics.
Bit-vector serialization class.
void gap_length_serialization(bool value) BMNOEXCEPT
Set GAP length serialization (serializes GAP levels of the original vector)
void byte_order_serialization(bool value) BMNOEXCEPT
Set byte-order serialization (for cross platform compatibility)
void optimize_serialize_destroy(BV &bv, typename serializer< BV >::buffer &buf)
Bitvector serialization into buffer object (resized automatically) Input bit-vector gets optimized an...
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
@ BM_GAP
GAP compression is ON.
size_t deserialize(BV &bv, const unsigned char *buf, bm::word_t *temp_block=0, const bm::bv_ref_vector< BV > *ref_vect=0)
Bitvector deserialization from a memory BLOB.
static void fill_bvector(bm::bvector<> *bv)
static void print_statistics(const bm::bvector<> &bv)
static unsigned char * serialize_bvector(bm::serializer< bm::bvector<> > &bvs, bm::bvector<> &bv)
size_t gap_blocks
Number of GAP blocks.
size_t bit_blocks
Number of bit blocks.
size_t max_serialize_mem
estimated maximum memory for serialization
size_t memory_used
memory usage for all blocks and service tables
Statistical information about bitset's memory allocation details.