68 for (; en.
valid() && cnt < 10; ++en, ++cnt)
72 cout <<
"(size = "<< bv.
size() <<
")" << endl;
87 target_buf.resize(sbuf.size());
88 ::memcpy(target_buf.data(), sbuf.buf(), sbuf.size());
156 vector<size_type> vect_B { 1, 2, 4 };
167 vector<size_type> vect_B { 1, 2, 4 };
169 const size_type* arr = &vect_B[0];
178 vector<unsigned char> blob;
268 vector<unsigned> vect_B { 1, 2, 4 };
278 vector<size_type> vect_B { 1, 2, 4 };
280 const size_type* arr = &vect_B[0];
289 vector<unsigned char> blob;
376 vector<unsigned> vect_B { 1, 2, 4 };
386 vector<unsigned char> blob;
449 vector<size_type> vect_B { 1, 2, 4 };
459 vector<size_type> vect_B { 1, 2, 4 };
461 const size_type* arr = &vect_B[0];
470 vector<unsigned char> blob;
536 bv_R.bit_or_and(bv_A, bv_B);
573 args = agg_pipe.
add();
578 args = agg_pipe.
add();
585 agg_pipe.set_or_target(&bv_T);
691 args = agg_pipe.
add();
698 args = agg_pipe.
add();
706 args = agg_pipe.
add();
716 agg_pipe.set_or_target(&bv_T);
725 auto& res_vect = agg_pipe.get_bv_res_vector();
726 assert(res_vect.size()==3);
727 for (
size_t i = 0; i < res_vect.size(); ++i)
735 cout <<
"Empty result" << endl;
751 cout << endl <<
"Set Union (OR) demo" << endl << endl;
754 cout << endl <<
"Set Intersect (AND) demo" << endl << endl;
757 cout << endl <<
"XOR demo" << endl << endl;
760 cout << endl <<
"Set Minus (SUB/AND-NOT) demo" << endl << endl;
763 cout << endl <<
"Set Invert (NOT) demo" << endl << endl;
766 cout << endl <<
"Set AND-SUB demo" << endl << endl;
769 cout << endl <<
"Set AND-OR demo" << endl << endl;
772 catch(std::exception& ex)
774 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Algorithms for fast aggregation of N bvectors.
Algorithms for bvector<> (main include)
Serialization / compression of bvector<>. Set theoretical operations on compressed BLOBs.
pre-processor un-defines to avoid global space pollution (internal)
static void DemoAND_SUB()
static void make_BLOB(vector< unsigned char > &target_buf, bm::bvector<> &bv)
static void print_bvector(const bm::bvector<> &bv)
Algorithms for fast aggregation of a group of bit-vectors.
bool combine_and_sub(bvector_type &bv_target)
Aggregate added group of vectors using fused logical AND-SUB Operation does NOT perform an explicit r...
void reset()
Reset aggregate groups, forget all attached vectors.
void combine_or(bvector_type &bv_target)
Aggregate added group of vectors using logical OR Operation does NOT perform an explicit reset of arg...
void combine_and(bvector_type &bv_target)
Aggregate added group of vectors using logical AND Operation does NOT perform an explicit reset of ar...
void set_optimization(typename bvector_type::optmode opt=bvector_type::opt_compress) BMNOEXCEPT
set on-the-fly bit-block compression By default aggregator does not try to optimize result,...
size_t add(const bvector_type *bv, unsigned agr_group=0)
Attach source bit-vector to a argument group (0 or 1).
Constant iterator designed to enumerate "ON" bits.
bool valid() const BMNOEXCEPT
Checks if iterator is still valid.
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
void merge(bm::bvector< Alloc > &bvect)
Merge/move content from another vector.
bvector< Alloc > & invert()
Invert/NEG all bits It should be noted, invert is affected by size() if size is set - it only inverts...
size_type size() const BMNOEXCEPT
Returns bvector's capacity (number of bits it can store)
bm::bvector< Alloc > & bit_and(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand AND : this := bv1 AND bv2
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
void resize(size_type new_size)
Change size of the bvector.
bm::bvector< Alloc > & bit_sub(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand SUB : this := bv1 MINUS bv2 SUBtraction is also known as AND NOT
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.
void clear(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
clear list of bits in this bitset
void combine_operation(const bm::bvector< Alloc > &bvect, bm::operation opcode)
perform a set-algebra operation by operation code
void keep(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
Keep list of bits in this bitset, others are cleared.
bm::bvector< Alloc > & bit_or_and(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand AND where result is ORed into the terget vector : this |= bv1 AND bv2 TARGET := TARGET OR (...
bm::bvector< Alloc > & bit_xor(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand XOR : this := bv1 XOR bv2
Deserializer, performs logical operations between bit-vector and serialized bit-vector.
size_type deserialize(bvector_type &bv, const unsigned char *buf, set_operation op, bool exit_on_one=false)
Deserialize bvector using buffer as set operation argument.
Bit-vector serialization class.
void set_compression_level(unsigned clevel) BMNOEXCEPT
Set compression level.
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
@ BM_SORTED
input set is sorted (ascending order)
void combine_and(BV &bv, It first, It last)
AND Combine bitvector and the iterable sequence.
void combine_sub(BV &bv, It first, It last)
SUB Combine bitvector and the iterable sequence.
void combine_xor(BV &bv, It first, It last)
XOR Combine bitvector and the iterable sequence.
void combine_or(BV &bv, It first, It last)
OR Combine bitvector and the iterable sequence.