1 #ifndef BMALGO__H__INCLUDED__
2 #define BMALGO__H__INCLUDED__
25 #ifndef BM__H__INCLUDED__
28 # error missing include (bm.h or bm64.h)
41 #define BM_SCANNER_OP(x) \
42 if (0 != (block = blk_blk[j+x])) \
44 if (BM_IS_GAP(block)) \
46 bm::for_each_gap_blk(BMGAP_PTR(block), (r+j+x)*bm::bits_in_block,\
51 bm::for_each_bit_blk(block, (r+j+x)*bm::bits_in_block,bit_functor); \
64 template<
class BV,
class Func>
68 typedef typename BV::size_type size_type;
70 const typename BV::blocks_manager_type& bman = bv.get_blocks_manager();
71 bm::word_t*** blk_root = bman.top_blocks_root();
76 unsigned tsize = bman.top_block_size();
77 for (
unsigned i = 0; i < tsize; ++i)
92 if (!avx2_test_all_zero_wave(blk_blk + j))
100 #elif defined(BM64_SSE4)
135 typedef typename BV::size_type size_type;
137 struct callback_adaptor
140 : handle_(h), func_(cb_func)
143 void add_bits(size_type offset,
const unsigned char* bits,
unsigned size)
145 for (
unsigned i = 0; i < size; ++i)
146 func_(handle_, offset + bits[i]);
148 void add_range(size_type offset,
unsigned size)
150 for (
unsigned i = 0; i < size; ++i)
151 func_(handle_, offset + i);
158 callback_adaptor func(handle_ptr, callback_ptr);
174 template<
typename BV>
190 void decompress(BV& bv_target,
const BV& bv_idx,
const BV& bv_src);
200 void compress(BV& bv_target,
const BV& bv_idx,
const BV& bv_src);
227 if (&bv_idx == &bv_src)
235 typedef typename BV::enumerator enumerator_t;
236 enumerator_t en_s = bv_src.first();
237 enumerator_t en_i = bv_idx.first();
242 for (; en_i.valid(); )
246 i = *en_i; s = *en_s;
253 ibuffer[b_size++] = r_idx++;
254 if (b_size == n_buffer_cap)
267 size_type r_dist = bv_idx.count_range(i + 1, s);
274 for (; s > i; ++r_idx)
301 if (&bv_idx == &bv_src)
312 typedef typename BV::enumerator enumerator_t;
313 enumerator_t en_s = bv_src.first();
314 enumerator_t en_i = bv_idx.first();
315 for (; en_i.valid(); )
323 ibuffer[b_size++] = i;
324 if (b_size == n_buffer_cap)
329 ++en_i; ++en_s; ++r_idx;
339 en_i.skip(s - r_idx);
345 bv_idx.find_rank(rank, i, new_pos);
352 ibuffer[b_size++] = new_pos;
353 if (b_size == n_buffer_cap)
358 ++en_i; ++en_s; ++r_idx;
383 : bv_target_(bv_out),
388 void add_bits(
size_type arr_offset,
const unsigned char* bits,
unsigned bits_size)
390 for (
unsigned i = 0; i < bits_size; ++i)
395 size_type r_idx = bv_index_.count_to(idx, bc_index_) - 1;
396 bv_target_.set_bit_no_check(r_idx);
406 size_type r_idx = bv_index_.count_to(idx, bc_index_) - 1;
407 bv_target_.set_bit_no_check(r_idx);
420 if (&bv_idx == &bv_src)
425 visitor_func func(bv_target, bv_idx, bc_idx);