Exmaple demonstrates bitvector serialization/deserialization.For more information please visit: http://bmagic.sourceforge.net
- See also
- bm::serializer
-
bm::deserialize
#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;
}
size_t max_serialize_mem
estimated maximum memory for serialization
void set_new_blocks_strat(strategy strat)
Sets new blocks allocation strategy.
static void fill_bvector(bm::bvector<> *bv)
size_type count() const
population cout (count of ON bits)
size_t bit_blocks
Number of bit blocks.
bm::bvector< Alloc > & bit_or(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode)
3-operand OR : this := bv1 OR bv2
size_t deserialize(BV &bv, const unsigned char *buf, bm::word_t *temp_block=0)
Bitvector deserialization from memory.
#define BM_DECLARE_TEMP_BLOCK(x)
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
static unsigned char * serialize_bvector(bm::serializer< bm::bvector<> > &bvs, bm::bvector<> &bv)
int compare(const bvector< Alloc > &bvect) const
Lexicographical comparison with a bitvector.
size_t gap_blocks
Number of GAP blocks.
void byte_order_serialization(bool value)
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...
void gap_length_serialization(bool value)
Set GAP length serialization (serializes GAP levels of the original vector)
static void print_statistics(const bm::bvector<> &bv)
@ BM_GAP
GAP compression is ON.
Bit-vector serialization class.
Serialization / compression of bvector<>. Set theoretical operations on compressed BLOBs.
size_t memory_used
memory usage for all blocks and service tables
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const
Calculates bitvector statistics.
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
bool set_bit(size_type n, bool val=true)
Sets bit n.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
Statistical information about bitset's memory allocation details.