A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/bmfunc_8h_source.html below:

NCBI C++ ToolKit: include/util/bitset/bmfunc.h Source File

1 #ifndef BMFUNC__H__INCLUDED__ 2 #define BMFUNC__H__INCLUDED__ 26 #include <type_traits> 33 # pragma warning( disable: 4146 ) 34 # pragma warning( disable: 4310 ) 41 template

<

bool

LWA=false,

bool

RWA=false>

85  size_t

mem_used = (capacity *

sizeof

(

gap_word_t

));

123  if

(!safe_inc) safe_inc = 1024;

206

std::cout <<

bc_arr

[

i

] <<

", "

;

210

std::cout << std::endl;

218 template

<

typename

First,

typename

Second>

244 template

<

typename

BI_TYPE>

256 template

<

typename

RTYPE>

266 template

<

typename

RTYPE>

269

RTYPE idx = bm::get_super_block_start<RTYPE>(

i

);

302  tmp

=

n

- ((

n

>> 1) & 033333333333)

303

- ((

n

>> 2) & 011111111111);

304  return

((

tmp

+ (

tmp

>> 3)) & 030707070707) % 63;

322

x = x - ((x >> 1) & m1);

323

y = y - ((y >> 1) & m1);

324

u = u - ((u >> 1) & m1);

325

v = v - ((v >> 1) & m1);

326

x = (x & m2) + ((x >> 2) & m2);

327

y = (y & m2) + ((y >> 2) & m2);

328

u = (u & m2) + ((u >> 2) & m2);

329

v = (v & m2) + ((v >> 2) & m2);

332

x = (x & m3) + ((x >> 4) & m3);

333

u = (u & m3) + ((u >> 4) & m3);

339  return

x & 0x000001FFU;

354 template

<

typename

T,

typename

F>

357  for

(

unsigned

sub_octet = 0; w != 0; w >>= 4, sub_octet += 4)

370

func(sub_octet, sub_octet + 1);

376

func(sub_octet, sub_octet + 2);

379

func(sub_octet + 1, sub_octet + 2);

382

func(sub_octet, sub_octet + 1, sub_octet + 2);

388

func(sub_octet, sub_octet + 3);

391

func(sub_octet + 1, sub_octet + 3);

394

func(sub_octet, sub_octet + 1, sub_octet + 3);

397

func(sub_octet + 2, sub_octet + 3);

400

func(sub_octet, sub_octet + 2, sub_octet + 3);

403

func(sub_octet + 1, sub_octet + 2, sub_octet + 3);

406

func(sub_octet, sub_octet + 1, sub_octet + 2, sub_octet + 3);

424 template

<

typename

T,

typename

F>

428  for

(

unsigned

octet = 0; w != 0; w >>= 8, octet += 8)

430  if

(w & 1) func(octet + 0);

431  if

(w & 2) func(octet + 1);

432  if

(w & 4) func(octet + 2);

433  if

(w & 8) func(octet + 3);

434  if

(w & 16) func(octet + 4);

435  if

(w & 32) func(octet + 5);

436  if

(w & 64) func(octet + 6);

437  if

(w & 128) func(octet + 7);

451  for

(

unsigned

sub_octet = 0; w; w >>= 4, sub_octet+=4)

458

bits[

cnt

++] = 0 + sub_octet;

461

bits[

cnt

++] = 1 + sub_octet;

464

bits[

cnt

] = 0 + sub_octet;

465

bits[

cnt

+1] = 1 + sub_octet;

469

bits[

cnt

++] = 2 + sub_octet;

472

bits[

cnt

+0] = 0 + sub_octet;

473

bits[

cnt

+1] = 2 + sub_octet;

477

bits[

cnt

+0] = 1 + sub_octet;

478

bits[

cnt

+1] = 2 + sub_octet;

482

bits[

cnt

+0] = 0 + sub_octet;

483

bits[

cnt

+1] = 1 + sub_octet;

484

bits[

cnt

+2] = 2 + sub_octet;

488

bits[

cnt

++] = 3 + sub_octet;

491

bits[

cnt

+0] = 0 + sub_octet;

492

bits[

cnt

+1] = 3 + sub_octet;

496

bits[

cnt

+0] = 1 + sub_octet;

497

bits[

cnt

+1] = 3 + sub_octet;

501

bits[

cnt

+0] = 0 + sub_octet;

502

bits[

cnt

+1] = 1 + sub_octet;

503

bits[

cnt

+2] = 3 + sub_octet;

507

bits[

cnt

+0] = 2 + sub_octet;

508

bits[

cnt

+1] = 3 + sub_octet;

512

bits[

cnt

+0] = 0 + sub_octet;

513

bits[

cnt

+1] = 2 + sub_octet;

514

bits[

cnt

+2] = 3 + sub_octet;

518

bits[

cnt

+0] = 1 + sub_octet;

519

bits[

cnt

+1] = 2 + sub_octet;

520

bits[

cnt

+2] = 3 + sub_octet;

524

bits[

cnt

+0] = 0 + sub_octet;

525

bits[

cnt

+1] = 1 + sub_octet;

526

bits[

cnt

+2] = 2 + sub_octet;

527

bits[

cnt

+3] = 3 + sub_octet;

537 #ifdef BM_NONSTANDARD_EXTENTIONS 545 unsigned

bitscan_nibble_gcc(

unsigned

w,

unsigned

* bits)

BMNOEXCEPT 547  static void

* d_table[] = { &&l0,

548

&&l1, &&l3_1, &&l3, &&l7_1, &&l5, &&l7_0, &&l7, &&l15_1,

549

&&l9, &&l11_0, &&l11, &&l15_0, &&l13, &&l14, &&l15 };

552  for

(

unsigned

sub_octet = 0; w; w >>= 4, sub_octet+=4)

554  goto

*d_table[w & 15];

556

bits[

cnt

++] = sub_octet;

559

bits[

cnt

++] = sub_octet;

561

bits[

cnt

++] = 1 + sub_octet;

564

bits[

cnt

++] = sub_octet;

567

bits[

cnt

++] = sub_octet;

569

bits[

cnt

++] = 1 + sub_octet;

571

bits[

cnt

++] = 2 + sub_octet;

574

bits[

cnt

++] = sub_octet;

578

bits[

cnt

++] = sub_octet;

580

bits[

cnt

++] = 1 + sub_octet;

581

bits[

cnt

++] = 3 + sub_octet;

584

bits[

cnt

++] = sub_octet;

587

bits[

cnt

++] = 1 + sub_octet;

590

bits[

cnt

++] = 0 + sub_octet;

591

bits[

cnt

++] = 1 + sub_octet;

593

bits[

cnt

++] = 2 + sub_octet;

595

bits[

cnt

++] = 3 + sub_octet;

608 template

<

typename

B>

622  bp_

[0] = (

B

)bit_idx0;

bp_

[1] = (

B

)bit_idx1;

630  bp_

[0] = (

B

)bit_idx0;

bp_

[1] = (

B

)bit_idx1;

bp_

[2] = (

B

)bit_idx2;

639  bp_

[0] = (

B

)bit_idx0;

bp_

[1] = (

B

)bit_idx1;

640  bp_

[2] = (

B

)bit_idx2;

bp_

[3] = (

B

)bit_idx3;

663

dest[nword] |= unsigned(1u << nbit);

676

dest[nword] &= ~(unsigned(1u << nbit));

690  return

(block[nword] >> nbit) & 1u;

704 template

<

typename

T,

typename

B>

709  return

(

unsigned

)(func.

ptr

() - bits);

722 template

<

typename

T,

typename

B>

727  return

(

unsigned

)(func.

ptr

() - bits);

740 template

<

typename

B>

751  return

(

unsigned short

)pos;

763 template

<

typename

B>

773  return

(

unsigned short

)pos;

784 template

<

typename

B>

787  unsigned short

pos = 0;

806 template

<

typename

B>

809  unsigned short

pos = 0;

818 template

<

typename

B,

typename

OT>

821  unsigned short

pos = 0;

839 template

<

typename

B>

842  unsigned short

pos = 0;

860 template

<

typename

B>

864  unsigned short

pos = 0;

878 template

<

typename

V,

typename

B>

882 #if (defined(__arm__) || defined(__aarch64__)) 883  if

constexpr (

sizeof

(V) == 8)

888  if

constexpr (

sizeof

(V) == 8)

914  for

(

unsigned count

= 0; w; w >>=1ull, ++

count

)

916

rank -= unsigned(w & 1ull);

1006  unsigned t

= w & -w;

1050 #if defined(BMI2_SELECT64) 1051  return

BMI2_SELECT64(w, rank);

1053  #if defined(BMI1_SELECT64) 1054  return

BMI2_SELECT64(w, rank);

1056  #if (defined(__arm__) || defined(__aarch64__)) 1077 #if defined(BMI2_SELECT64) 1078  return

BMI2_SELECT64(w, rank);

1080  #if defined(BMI1_SELECT64) 1081  return

BMI2_SELECT64(w, rank);

1083  #if (defined(__arm__) || defined(__aarch64__)) 1120  for

(

unsigned i

= from;

i

<= to; ++

i

)

1121

m |= (1ull << (

i

/ 1024));

1143

((~0ull) >> (63 - (digest_to - digest_from))) << digest_from;

1165  unsigned

bitpos_from,

unsigned

bitpos_to)

BMNOEXCEPT 1168  return

!(digest &

mask

);

1185  bool

curr = digest &

mask

;

1186  if

(curr && curr !=

prev

)

1204  for

(

unsigned i

= 0;

i

< 64; ++

i

)

1209 #if defined(VECT_BLOCK_SET_DIGEST) 1214

block[off] = block[off+1] = block[off+2] = block[off+3] =

mask

;

1235  for

(

unsigned i

= 0;

i

< 64; ++

i

)

1238  #if defined(VECT_IS_DIGEST_ZERO) 1245  bm::word_t

w = block[off+j+0] | block[off+j+1] |

1246

block[off+j+2] | block[off+j+3];

1249

digest0 |= (

mask

<<

i

);

1285  #if defined(VECT_IS_DIGEST_ZERO) 1287

digest &= all_zero ? ~(

mask

<< wave) : digest;

1296

src_u->w64[j+0] | src_u->w64[j+1] | src_u->w64[j+2] | src_u->w64[j+3];

1299

digest &= w64 ? digest : ~(

mask

<< wave);

1326  unsigned

t_wave = 0;

1341  for

(; sub_block < sub_block_end; t_sub_block+=4, sub_block+=4)

1343

t_sub_block[0] = sub_block[0];

1344

t_sub_block[1] = sub_block[1];

1345

t_sub_block[2] = sub_block[2];

1346

t_sub_block[3] = sub_block[3];

1363  for

(; t_sub_block < t_sub_block_end; t_sub_block+=4)

1393  unsigned

s_wave = 0;

1400  const bm::word_t

* sub_block = block + s_off;

1407  for

(; sub_block < sub_block_end; t_sub_block+=4, sub_block+=4)

1409

t_sub_block[0] = sub_block[0];

1410

t_sub_block[1] = sub_block[1];

1411

t_sub_block[2] = sub_block[2];

1412

t_sub_block[3] = sub_block[3];

1423  for

(; t_sub_block < t_sub_block_end; t_sub_block+=4)

1425

t_sub_block[0] = 0; t_sub_block[1] = 0;

1426

t_sub_block[2] = 0; t_sub_block[3] = 0;

1442  return

(

int

(op) >=

int

(

set_COUNT

));

1475

::memset(_p, 0xFF,

sizeof

(_p));

1476  if

constexpr (

sizeof

(

void

*) == 8)

1478  const unsigned long long

magic_mask = 0xFFFFfffeFFFFfffe;

1479

::memcpy(&_p_fullp, &magic_mask,

sizeof

(magic_mask));

1481

_s[

i

] =

reinterpret_cast<bm::word_t

*

>

(magic_mask);

1485  const unsigned

magic_mask = 0xFFFFfffe;

1486

::memcpy(&_p_fullp, &magic_mask,

sizeof

(magic_mask));

1488

_s[

i

] =

reinterpret_cast<bm::word_t

*

>

(magic_mask);

1499  if

constexpr (

sizeof

(

void

*) == 8)

1501  bm::id64_t

w =

reinterpret_cast<unsigned long long>

(bp);

1508  unsigned

w =

reinterpret_cast<unsigned long>

(bp);

1536 template

<

typename

N>

1545  const unsigned

unroll_factor = 4;

1546  const unsigned len

= (

size

- start);

1547  const unsigned

len_unr =

len

- (

len

% unroll_factor);

1551  for

(k = 0; k < len_unr; k+=unroll_factor)

1562

*pos = k + start + 1;

1567

*pos = k + start + 2;

1572

*pos = k + start + 3;

1578  for

(; k <

len

; ++k)

1587  for

(; start <

size

; ++start)

1617  int

res = (w1 & 1) - (w2 & 1);

1618  if

(res != 0)

return

res;

1645  return

diff? ( (

a

& diff & -diff)? 1 : -1 ) : 0;

1662 #if defined(VECT_IS_ZERO_BLOCK) 1669  if

(blk[0] | blk[1] | blk[2] | blk[3])

1672

}

while

(blk < blk_end);

1727 template

<

typename

T>

1731  return

glevel_len[(*

buf

>> 1) & 3];

1743 template

<

typename

T>

1747  return

glevel_len[(*

buf

>> 1) & 3]-4;

1758 template

<

typename

T>

1761  return T

((*

buf

>> 1) & 3u);

1775 template

<

typename

T>

1781  T

is_set = (*buf) & 1u;

1782  T

end =

T

((*

buf

) >> 3u);

1786

is_set ^=

T

((end-1) & 1u);

1806 template

<

typename

T>

1812  T

is_set = (*buf) & 1u;

1834 template

<

typename

T>

1840  #if defined(VECT_GAP_BFIND) 1844  unsigned

end = ((*buf) >> 3);

1846  unsigned size

= end - start;

1847  for

(;

size

>= 64;

size

= end - start)

1849  unsigned

mid = (start + end) >> 1;

1850  if

(

buf

[mid] < pos)

1854  if

(

buf

[mid = (start + end) >> 1] < pos)

1858  if

(

buf

[mid = (start + end) >> 1] < pos)

1862  if

(

buf

[mid = (start + end) >> 1] < pos)

1868  for

(;

size

>= 16;

size

= end - start)

1870  if

(

unsigned

mid = (start + end) >> 1;

buf

[mid] < pos)

1874  if

(

unsigned

mid = (start + end) >> 1;

buf

[mid] < pos)

1880  for

(;

true

; ++start)

1881  if

(

buf

[start] >= pos)

1884

*is_set = ((*buf) & 1) ^ ((start-1) & 1);

1899 template

<

typename

T>

1905  unsigned

end = 1 + ((*buf) >> 3);

1906  if

(end - start < 10)

1908  unsigned

sv = *

buf

& 1;

1909  unsigned

sv1= sv ^ 1;

1910  if

(

buf

[1] >= pos)

return

sv;

1911  if

(

buf

[2] >= pos)

return

sv1;

1912  if

(

buf

[3] >= pos)

return

sv;

1913  if

(

buf

[4] >= pos)

return

sv1;

1914  if

(

buf

[5] >= pos)

return

sv;

1915  if

(

buf

[6] >= pos)

return

sv1;

1916  if

(

buf

[7] >= pos)

return

sv;

1917  if

(

buf

[8] >= pos)

return

sv1;

1926  if

(

unsigned

mid = (start + end) >> 1;

buf

[mid] < pos)

1930

}

while

(start != end);

1932  return

((*

buf

) & 1) ^ ((--start) & 1);

1942 template

<

typename

T>

1948 #if defined(VECT_GAP_TEST) 1960 template

<

typename

T,

typename

N,

typename

F>

1965  if

(nb_from > nb_to)

1972  if

(i_from >= top_size)

1974  if

(i_to >= top_size)

1976

i_to = unsigned(top_size-1);

1980  for

(

unsigned i

= i_from;

i

<= i_to; ++

i

)

1982  T

** blk_blk = root[

i

];

1987  unsigned

j = (

i

== i_from) ? j_from : 0;

1988  if

(!j && (

i

!= i_to))

1995  if

((

i

== i_to) && (j == j_to))

2002  unsigned

j = (

i

== i_from) ? j_from : 0;

2007  if

((

i

== i_to) && (j == j_to))

2017 template

<

class

T,

class

F>

2020  typedef typename

F::size_type size_type;

2021  for

(

unsigned i

= 0;

i

< size1; ++

i

)

2023  T

** blk_blk = root[

i

];

2026  f

.on_empty_top(

i

);

2029  f

.on_non_empty_top(

i

);

2041  unsigned

non_empty_top = 0;

2046 #if defined(BM64_AVX2) || defined(BM64_AVX512) 2050  T

* blk0 = blk_blk[j + 0];

2051  T

* blk1 = blk_blk[j + 1];

2052  T

* blk2 = blk_blk[j + 2];

2053  T

* blk3 = blk_blk[j + 3];

2055

size_type block_idx =

r

+ j + 0;

2057  f

(blk0, block_idx);

2059  f

.on_empty_block(block_idx);

2062  f

(blk1, block_idx + 1);

2064  f

.on_empty_block(block_idx + 1);

2067  f

(blk2, block_idx + 2);

2069  f

.on_empty_block(block_idx + 2);

2072  f

(blk3, block_idx + 3);

2074  f

.on_empty_block(block_idx + 3);

2078  f

.on_empty_block(

r

+ j + 0);

f

.on_empty_block(

r

+ j + 1);

2079  f

.on_empty_block(

r

+ j + 2);

f

.on_empty_block(

r

+ j + 3);

2082 #elif defined(BM64_SSE4) 2086  T

* blk0 = blk_blk[j + 0];

2087  T

* blk1 = blk_blk[j + 1];

2089

size_type block_idx =

r

+ j + 0;

2091  f

(blk0, block_idx);

2093  f

.on_empty_block(block_idx);

2097  f

(blk1, block_idx);

2099  f

.on_empty_block(block_idx);

2103  f

.on_empty_block(

r

+ j + 0);

2104  f

.on_empty_block(

r

+ j + 1);

2110  f

(blk_blk[j],

r

+ j);

2114  f

.on_empty_block(

r

+ j);

2119  if

(non_empty_top == 0)

2120  f

.on_empty_top(

i

);

2126 template

<

class

T,

class

F>

2130  for

(

unsigned i

= 0;

i

< size1; ++

i

)

2133  if

((blk_blk = root[

i

])!=0)

2150  T

* blk0 = blk_blk[j + 0];

2151  T

* blk1 = blk_blk[j + 1];

2161  T

* blk0 = blk_blk[j + 2];

2162  T

* blk1 = blk_blk[j + 3];

2172 #elif defined(BM64_AVX2) || defined(BM64_AVX512) 2173  for

(

unsigned i

= 0;

i

< size1; ++

i

)

2176  if

((blk_blk = root[

i

]) != 0)

2189

__m256i w0 = _mm256_loadu_si256((__m256i*)(blk_blk + j));

2190  if

(!_mm256_testz_si256(w0, w0))

2194  T

* blk0 = blk_blk[j + 0];

2195  T

* blk1 = blk_blk[j + 1];

2196  T

* blk2 = blk_blk[j + 2];

2197  T

* blk3 = blk_blk[j + 3];

2213  for

(

unsigned i

= 0;

i

< size1; ++

i

)

2216  if

((blk_blk = root[

i

])!=0)

2248 template

<

typename

T,

typename

BI,

typename

F>

2252  for

(BI

i

= 0;

i

< size1; ++

i

)

2254  T

** blk_blk = root[

i

];

2273  if

(

f

(blk_blk[j], block_idx))

2282 template

<

class

T,

class

F,

typename

BLOCK_IDX>

2285

BLOCK_IDX block_idx = start;

2286  for

(

unsigned i

= 0;

i

< size1; ++

i

)

2288  T

** blk_blk = root[

i

];

2301  f

(blk_blk[j], block_idx);

2330 template

<

typename

T>

2349 template

<

typename

T>

2358  for

(

unsigned i

= 1;

i

< arr_len; ++

i

)

2388 template

<

typename

T>

2395  if

(arr_len <= wlen)

2397  unsigned

min_w_prev = ~0u;

2399  for

(

unsigned i

= 1;

i

< wlen; ++

i

)

2403

min_w_prev =

delta

;

2405

min_w_prev -=

bool

(min_w_prev);

2409  for

(

unsigned i

= wlen;

i

< arr_len; ++wave,

i

+=wlen)

2411  if

(

i

+ wlen > arr_len)

2413  unsigned r

= arr_len % wlen;

2418  unsigned

min_w = ~0u;

2419  for

(

unsigned

j = 0; j < wlen; ++j)

2424  if

(

delta

<= min_w_prev)

2432  if

(min_w_prev && (min_w > min0))

2439

min_w_prev = (min_w > min0) ? min_w - 1 : min0;

2449 template

<

typename

T>

2460  T

min_w_prev =

T

(~0u);

2462  for

(

unsigned i

= 1;

i

< wlen; ++

i

)

2467

min_w_prev =

delta

;

2471

tarr[

i

] =

arr

[

i

] - min0 - delta_acc;

2475

min_w_prev -=

bool

(min_w_prev);

2478  for

(

unsigned

wave = 1,

i

=wlen;

i

< arr_len;

i

+=wlen, ++wave)

2480  if

(

i

+ wlen > arr_len)

2482  unsigned r

= arr_len % wlen;

2488  for

(

unsigned

j = 0; j < wlen; ++j)

2497

tarr[

i

+j] =

arr

[

i

+j] - min_w_prev - delta_acc;

2498

delta_acc += min_w_prev;

2502

tarr[

i

+j] =

arr

[

i

+j] - min0 - delta_acc;

2507

min_w_prev = (min_w > min0) ? min_w - 1 : min0;

2516 template

<

typename

T>

2526  unsigned

min_w_prev = ~0u;

2528  for

(

unsigned i

= 1;

i

< wlen; ++

i

)

2531  arr

[

i

] += min0 + delta_acc;

2537

min_w_prev =

delta

;

2541

min_w_prev -=

bool

(min_w_prev);

2545  for

(

unsigned i

= wlen;

i

< arr_len; ++wave,

i

+=wlen)

2547  if

(

i

+ wlen > arr_len)

2549  unsigned r

= arr_len % wlen;

2554  unsigned

min_w = ~0u;

2555  for

(

unsigned

j = 0; j < wlen; ++j)

2559  arr

[

i

+j] += (

T

)(min_w_prev + delta_acc);

2560

delta_acc += (

T

)min_w_prev;

2564  arr

[

i

+j] += min0 + delta_acc;

2571

min_w_prev = (min_w > min0) ? min_w - 1 : min0;

2583 template

<

typename

T>

2585  unsigned

* hist,

unsigned

hist_len)

BMNOEXCEPT 2588  for

(

unsigned i

= 1;

i

< arr_len; ++

i

)

2594  if

(

delta

< hist_len)

2604 template

<

typename

T>

2606  T

* arr_dst,

unsigned

& dst_len,

2607  const T

*

arr

,

unsigned

arr_len,

2612

d1_len = dst_len = 0;

2613

arr_dst[dst_len] =

arr

[dst_len];

2616  for

(

unsigned i

= 1;

i

< arr_len; ++

i

)

2620  if

(

delta

<= ex_max_delta)

2621

arr_d1[d1_len++] =

arr

[

i

];

2623

arr_dst[dst_len++] =

arr

[

i

];

2631 template

<

typename

T>

2634

tarr[0] =

arr

[0] - delta_acc;

2635  for

(

unsigned i

= 1;

i

< arr_len; ++

i

)

2637

tarr[

i

] =

arr

[

i

] - min0 - delta_acc;

2647 template

<

typename

T>

2650  arr

[0] =

arr

[0] + delta_acc;

2651  for

(

unsigned i

= 1;

i

< arr_len; ++

i

)

2653  arr

[

i

] += min0 + delta_acc;

2665 template

<

typename

T>

2668  const T

* pcurr =

buf

;

2669  auto

dsize = (*pcurr >> 3);

2671  const T

* pend = pcurr + dsize;

2676  for

(++pcurr; pcurr <= pend; pcurr++)

2678  T delta

= *pcurr - *(pcurr-1);

2684  delta

= *pcurr - *(pcurr-1);

2702 template

<

typename

T>

2704  unsigned

* hist0,

unsigned

* hist1,

unsigned

hist_len

2707  const T

* pcurr =

buf

;

2710  unsigned

is_set = (*pcurr & 1u);

2712  const T

* pend = pcurr + dsize;

2716  if

(

delta

< hist_len)

2721  for

(++pcurr; pcurr <= pend; pcurr++, is_set ^= 1u)

2723  delta

= *pcurr - *(pcurr-1);

2724  if

(

delta

< hist_len)

2728

++pcurr; is_set ^= 1u;

2731  delta

= *pcurr - *(pcurr-1);

2732  if

(

delta

< hist_len)

2741 template

<

typename

T>

2790 template

<

typename

T>

2793  const unsigned

* hist0,

const unsigned

* hist1,

2794  T

* tbuf,

T

* ex0_arr,

T

* ex1_arr,

2795  unsigned

& ex0_cnt,

unsigned

& ex1_cnt)

BMNOEXCEPT 2797  bool

ex0_first =

true

;

2798

ex0_cnt = ex1_cnt = 0;

2799  unsigned

dsize =

len

;

2801

::memcpy(tbuf,

buf

, (1+dsize) *

sizeof

(

T

));

2804  for

(

T i

= 1;

i

< h_limit; ++

i

)

2806  unsigned

ex0_cnt_s {ex0_cnt}, ex1_cnt_s {ex1_cnt};

2808  bool

h0_flag{0}, h1_flag{0};

2809  if

(hist0[

i

] < hist1[

i

])

2819  if

(hist0[

i

] == 0)

2823  const T

* pcurr = tbuf+1;

2824

dsize = (*tbuf >> 3);

2825  const T

* pend = pcurr + dsize;

2826  unsigned

is_set = (*tbuf & 1u);

2829  if

(

delta

<

i

&& !is_set)

2830  for

(

unsigned

j = 0; j <= *pcurr; ++j)

2831

ex0_arr[ex0_cnt++] = (

T

)j;

2832  for

(++pcurr, is_set ^= 1u; pcurr <= pend; ++pcurr,is_set ^= 1u)

2834  delta

= *pcurr - *(pcurr-1);

2835  if

(

delta

<=

i

&& !is_set)

2836  for

(

unsigned

j = *(pcurr-1)+1; j <= *pcurr; ++j)

2837

ex0_arr[ex0_cnt++] = (

T

)j;

2839

++pcurr; is_set ^= 1u;

2842  delta

= *pcurr - *(pcurr-1);

2843  if

(

delta

<=

i

&& !is_set)

2844  for

(

unsigned

j = *(pcurr-1)+1; j <= *pcurr; ++j)

2845

ex0_arr[ex0_cnt++] = (

T

)j;

2848  auto

new_len = dsize;

2849  for

(

unsigned

k = ex0_cnt_s; k < ex0_cnt; ++k)

2867  if

(hist1[

i

] == 0)

2871  const T

* pcurr = tbuf+1;

2873  const T

* pend = pcurr + (*tbuf >> 3);

2874  unsigned

is_set = (*tbuf & 1u);

2877  if

(

delta

<

i

&& is_set)

2878  for

(

unsigned

j = 0; j <= *pcurr; ++j)

2879

ex1_arr[ex1_cnt++] = (

T

)j;

2881  for

(++pcurr; pcurr <= pend; ++pcurr,is_set ^= 1u)

2883  delta

= *pcurr - *(pcurr-1);

2884  if

(

delta

<=

i

&& is_set)

2885  for

(

unsigned

j = *(pcurr-1)+1; j <= *pcurr; ++j)

2886

ex1_arr[ex1_cnt++] = (

T

)j;

2888

++pcurr; is_set ^= 1u;

2891  delta

= *pcurr - *(pcurr-1);

2892  if

(

delta

<=

i

&& is_set)

2893  for

(

unsigned

j = *(pcurr-1)+1; j <= *pcurr; ++j)

2894

ex1_arr[ex1_cnt++] = (

T

)j;

2897  auto

new_len = dsize;

2898  for

(

unsigned

k = ex1_cnt_s; k < ex1_cnt; ++k)

2904  BM_ASSERT

(dsize >= new_len); (void) new_len;

2925  unsigned

ex_limit,

unsigned

* ex_sum)

BMNOEXCEPT 2930  for

(

i

= 0; (

i

< hist_len) && (*ex_sum < ex_limit); ++

i

)

2932

*ex_sum += hist0[

i

] + hist1[

i

];

2945 template

<

typename

T>

2948  const T

* pcurr =

buf

;

2949  auto

dsize = (*pcurr >> 3);

2950  const T

* pend = pcurr + dsize;

2957  T prev

= *tcurr = (*pcurr - min0); (void)

prev

;

2961  for

(; pcurr <= pend; )

2972  prev

= *tcurr = *pcurr - min1 - delta_acc;

2979  prev

= *tcurr = *pcurr - min0 - delta_acc;

2999 template

<

typename

T>

3003  auto

dsize = (*pcurr >> 3);

3004  const T

* pend = pcurr + dsize;

3008

*pcurr = (*pcurr + min0);

3011  for

(++pcurr; pcurr <= pend; )

3019

*pcurr = *pcurr + min1 + delta_acc;

3024

*pcurr = *pcurr + min0 + delta_acc;

3042 template

<

typename

T>

3045  const T

* pcurr =

buf

;

3047

dsize = (*pcurr >> 3);

3048  const T

* pend = pcurr + dsize;

3053  for

(; pcurr <= pend; pcurr++)

3069 template

<

typename

T>

3072  const T

* pcurr =

buf

;

3074

dsize = (*pcurr >> 3);

3076  const T

* pend = pcurr + dsize;

3078  unsigned

bits_counter = 0;

3083

bits_counter += *pcurr + 1;

3086  for

(++pcurr; pcurr <= pend; pcurr += 2)

3087

bits_counter += *pcurr - *(pcurr-1);

3088  return

bits_counter;

3097 template

<

typename

T>

3100  const T

* pcurr =

buf

;

3101  unsigned

dsize = (*pcurr >> 3);

3105  T

first_one = *

buf

& 1;

3113  #if defined(BMAVX2OPT) || defined(BMAVX512OPT) 3116  const unsigned

unr_factor = 32;

3117  unsigned

waves = (dsize-2) / unr_factor;

3120  #elif defined(BMSSE42OPT) || defined(BMSSE2OPT) 3123  const unsigned

unr_factor = 16;

3124  unsigned

waves = (dsize - 2) / unr_factor;

3130  const unsigned

unr_factor = 8;

3131  unsigned

waves = (dsize - 2) / unr_factor;

3132  for

(

unsigned i

= 0;

i

< waves;

i

+= unr_factor)

3134  cnt

+= pcurr[0] - pcurr[0 - 1];

3135  cnt

+= pcurr[2] - pcurr[2 - 1];

3136  cnt

+= pcurr[4] - pcurr[4 - 1];

3137  cnt

+= pcurr[6] - pcurr[6 - 1];

3139

pcurr += unr_factor;

3144  const T

* pend =

buf

+ dsize;

3145  for

( ; pcurr <= pend ; pcurr+=2)

3146  cnt

+= *pcurr - *(pcurr - 1);

3163 template

<

typename

T,

bool

RIGHT_END = false>

3170  unsigned

is_set, bits_counter, prev_gap;

3172

is_set = ~(is_set - 1u);

3174  const T

* pcurr =

buf

+ start_pos;

3175  if

(right <= *pcurr)

3176

bits_counter = unsigned(right - left + 1u) & is_set;

3179

bits_counter = unsigned(*pcurr - left + 1u) & is_set;

3180  if

constexpr (RIGHT_END)

3183  for

(prev_gap = *pcurr++ ;

true

; prev_gap = *pcurr++)

3185

bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);

3192  for

(prev_gap = *pcurr++; right > *pcurr; prev_gap = *pcurr++)

3193

bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);

3194

bits_counter += unsigned(right - prev_gap) & (is_set ^ ~0u);

3197  return

bits_counter;

3206 template

<

typename

T>

3208  const unsigned

start_pos,

3211  unsigned

is_set_c, pos;

3213  bool r

= (pos == (start_pos) &&

bool

(is_set) ==

bool

(is_set_c));

3214  BM_ASSERT

(

bool

(is_set) ==

bool

(is_set_c));

3230 template

<

typename

T>

3232  unsigned

left,

unsigned

right,

unsigned

hint)

BMNOEXCEPT 3237  unsigned

is_set, bits_counter, prev_gap;

3241

is_set = ~(is_set - 1u);

3242  unsigned

start_pos = hint >> 1;

3254  const T

* pcurr =

buf

+ start_pos;

3255  if

(right <= *pcurr)

3256

bits_counter = unsigned(right - left + 1u) & is_set;

3259

bits_counter = unsigned(*pcurr - left + 1u) & is_set;

3260  for

(prev_gap = *pcurr++; right > *pcurr; prev_gap = *pcurr++)

3261

bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);

3262

bits_counter += unsigned(right - prev_gap) & (is_set ^ ~0u);

3264  return

bits_counter;

3276 template

<

typename

T>

3287  const T

*

const

pcurr =

buf

+ start_pos;

3288  return

(right <= *pcurr);

3299 template

<

typename

T>

3308  const T

*

const

pcurr =

buf

+ start_pos;

3312  if

(right <= *pcurr)

3328 template

<

typename

T>

3339  const T

* pcurr =

buf

+ start_pos;

3340  if

(!is_set || (right != *pcurr) || (start_pos <= 1))

3343  if

(*pcurr != left-1)

3357 template

<

typename

T>

3368

*pos =

buf

[start_pos];

3382 template

<

typename

T>

3397

*pos =

buf

[start_pos]+1;

3410 template

<

typename

T>

3428

*pos =

buf

[start_pos];

3447 template

<

typename

T,

typename

SIZE_TYPE>

3456  const T

* pcurr = block;

3457  const T

* pend = pcurr + (*pcurr >> 3);

3459  unsigned

bits_counter = 0;

3461  unsigned

start_pos =

bm::gap_bfind

(block, nbit_from, &is_set);

3462

is_set = ~(is_set - 1u);

3464

pcurr = block + start_pos;

3465

bits_counter += unsigned(*pcurr - nbit_from + 1u) & is_set;

3466  if

(bits_counter >= rank)

3468

nbit_pos = nbit_from + unsigned(rank) - 1u;

3471

rank -= bits_counter;

3472  unsigned

prev_gap = *pcurr++;

3473  for

(is_set ^= ~0u; pcurr <= pend; is_set ^= ~0u)

3475

bits_counter = (*pcurr - prev_gap) & is_set;

3476  if

(bits_counter >= rank)

3478

nbit_pos = prev_gap + unsigned(rank);

3481

rank -= bits_counter;

3482

prev_gap = *pcurr++;

3489 template

<

typename

T,

bool

TCORRECT=false>

3494  unsigned

bits_counter, prev_gap;

3496  unsigned

is_set = ~((unsigned(*

buf

) & 1u) - 1u);

3497  const T

* pcurr =

buf

+ 1;

3498  if

(right <= *pcurr)

3500

bits_counter = (right + 1u) & is_set;

3504

bits_counter = (*pcurr + 1u) & is_set;

3505

prev_gap = *pcurr++;

3506  for

(is_set ^= ~0u; right > *pcurr; is_set ^= ~0u, prev_gap = *pcurr++)

3508

bits_counter += (*pcurr - prev_gap) & is_set;

3512

bits_counter += (right - prev_gap) & is_set;

3516  if

constexpr (TCORRECT)

3517

bits_counter -= (is_set & unsigned(TCORRECT));

3518  return

bits_counter;

3532 template

<

class

T,

class

Func>

3535  const T

* pcurr = gap_buf;

3536  const T

* pend = pcurr + (*pcurr >> 3);

3540

func((

T

)(

prev

+ 1));

3544

func((

T

)(*pcurr -

prev

));

3546

}

while

(++pcurr < pend);

3573 template

<

typename

T>

3579

*dgap_buf++ = *gap_buf;

3583

for_each_dgap<T, d_copy_func<T> >(gap_buf, copy_func);

3599 template

<

typename

T>

3603  const T

* pcurr = dgap_buf;

3608

*gap_buf++ = *pcurr++;

3612  len

= gap_header >> 3;

3613

*gap_buf++ = gap_header;

3616  const T

* pend = pcurr +

len

;

3618

*gap_buf = *pcurr++;

3622

*gap_buf =

T

(*gap_buf - 1);

3624  for

(++gap_buf; pcurr < pend; ++pcurr)

3626  T prev

= *(gap_buf-1);

3627

*gap_buf++ =

T

(*pcurr +

prev

);

3641 template

<

typename

T>

3644  const T

* pcurr1 = buf1;

3645  const T

* pend1 = pcurr1 + (*pcurr1 >> 3);

3646  unsigned

bitval1 = *buf1 & 1;

3649  const T

* pcurr2 = buf2;

3650  unsigned

bitval2 = *buf2 & 1;

3653  while

(pcurr1 <= pend1)

3655  if

(*pcurr1 == *pcurr2)

3657  if

(bitval1 != bitval2)

3659  return

(bitval1) ? 1 : -1;

3664  if

(bitval1 == bitval2)

3668  return

(*pcurr1 < *pcurr2) ? -1 : 1;

3672  return

(*pcurr1 < *pcurr2) ? 1 : -1;

3677  return

(bitval1) ? 1 : -1;

3697 template

<

typename

T>

3704  const T

* pcurr1 = buf1;

3705  const T

* pend1 = pcurr1 + (*pcurr1 >> 3);

3706  const T

* pcurr2 = buf2;

3707  for

(++pcurr1, ++pcurr2; pcurr1 <= pend1; ++pcurr1, ++pcurr2)

3709  if

(*pcurr1 != *pcurr2)

3711

*pos = 1 + ((*pcurr1 < *pcurr2) ? *pcurr1 : *pcurr2);

3737 template

<

typename

T,

class

F>

3740  unsigned

vect1_mask,

3742  unsigned

vect2_mask,

3745  const T

* cur1 = vect1;

3746  const T

* cur2 = vect2;

3748  T

bitval1 = (

T

)((*cur1++ & 1) ^ vect1_mask);

3749  T

bitval2 = (

T

)((*cur2++ & 1) ^ vect2_mask);

3751  T

bitval = (

T

) F::op(bitval1, bitval2);

3752  T

bitval_prev = bitval;

3758  T

c1 = *cur1;

T

c2 = *cur2;

3761

bitval = (

T

) F::op(bitval1, bitval2);

3766

res += (bitval != bitval_prev);

3767

bitval_prev = bitval;

3787

bitval1 ^= 1; bitval2 ^= 1;

3793

dlen = (unsigned)(res - dest);

3794

*dest = (

T

)((*dest & 7) + (dlen << 3));

3812 template

<

typename

T,

class

F>

3814  unsigned

vect1_mask,

3818  const T

* cur1 = vect1;

3819  const T

* cur2 = vect2;

3821  unsigned

bitval1 = (*cur1++ & 1) ^ vect1_mask;

3822  unsigned

bitval2 = (*cur2++ & 1) ^ vect2_mask;

3824  unsigned

bitval = F::op(bitval1, bitval2);

3827  unsigned

bitval_prev = bitval;

3831

bitval = F::op(bitval1, bitval2);

3835  if

(bitval != bitval_prev)

3836

bitval_prev = bitval;

3856

bitval1 ^= 1; bitval2 ^= 1;

3877 template

<

typename

T,

class

F>

3881  const T

* cur1 = vect1;

3882  const T

* cur2 = vect2;

3884  unsigned

bitval1 = (*cur1++ & 1);

3885  unsigned

bitval2 = (*cur2++ & 1);

3886  unsigned

bitval =

count

= F::op(bitval1, bitval2);

3887  unsigned

bitval_prev = bitval;

3894

bitval = F::op(bitval1, bitval2);

3897  if

(bitval != bitval_prev)

3899

bitval_prev = bitval;

3908  count

+= res - res_prev;

3911

++cur1; bitval1 ^= 1;

3918  count

+= res - res_prev;

3931

bitval1 ^= 1; bitval2 ^= 1;

3943 #pragma GCC diagnostic push 3944 #pragma GCC diagnostic ignored "-Wconversion" 3961 template

<

typename

T>

3968  T

end = (

T

)(*

buf

>> 3);

3969  if

(*is_set ==

val

)

3976  T

* pcurr =

buf

+ curr;

3977  T

* pprev = pcurr - 1;

3978  T

* pend =

buf

+ end;

3993

pprev =

buf

+ 1; pcurr = pprev + 1;

3998  if

(curr > 1 && ((

unsigned

)(*pprev))+1 == pos)

4001  if

(*pprev == *pcurr)

4009  do

{ *pprev++ = *pcurr++; }

while

(pcurr < pend);

4017

end += (pcurr == pend);

4022  ::memmove

(pcurr+2, pcurr, (end - curr + 1)*(

sizeof

(

T

)));

4024

pcurr[0] = (

T

)(pos-1);

4025

pcurr[1] = (

T

)pos;

4029

*

buf

= (

T

)((*

buf

& 7) + (end << 3));

4047 template

<

typename

T>

4074 template

<

typename

T>

4082  T

end = (

T

) (*

buf

>> 3);

4086  T

* pcurr =

buf

+ curr;

4087  T

* pprev = pcurr - 1;

4088  T

* pend =

buf

+ end;

4103

pprev =

buf

+ 1; pcurr = pprev + 1;

4108  if

(curr > 1 && ((

unsigned

)(*pprev))+1 == pos)

4111  if

(*pprev == *pcurr)

4119  do

{ *pprev++ = *pcurr++; }

while

(pcurr < pend);

4127

end += (pcurr == pend);

4132  ::memmove

(pcurr+2, pcurr, (end - curr + 1)*(

sizeof

(

T

)));

4134

pcurr[0] = (

T

)(pos-1);

4135

pcurr[1] = (

T

)pos;

4139

*

buf

= (

T

)((*

buf

& 7) + (end << 3));

4152 template

<

typename

T>

4157  T

end = (

T

)(*

buf

>> 3);

4159  T

* pcurr =

buf

+ end;

4161  T

* pprev = pcurr - 1;

4176

pprev =

buf

+ 1; pcurr = pprev + 1;

4178  do

{ *pprev++ = *pcurr++; }

while

(pcurr < pend);

4181  else if

(((

unsigned

)(*pprev))+1 == pos && (curr > 1) )

4184  if

(*pprev == *pcurr)

4190  else if

(*pcurr == pos)

4193

end += (pcurr == pend);

4197

pcurr[0] = (

T

)(pos-1);

4198

pcurr[1] = (

T

)pos;

4203

*

buf

= (

T

)((*

buf

& 7) + (end << 3));

4209 #pragma GCC diagnostic pop 4222 template

<

typename

T>

4229  bool

co, gap_set_flag;

4230  unsigned len

= (*

buf

>> 3);

4233  unsigned

bitval = *

buf

& 1;

4234

gap_set_flag = (bitval != co_flag);

4240  for

(;

i

<

len

; ++

i

)

4275 template

<

typename

T>

4282  bool

co, gap_set_flag;

4287

gap_set_flag = (

val

!= is_set);

4288  unsigned len

= (*

buf

>> 3);

4298  for

(;

i

<

len

; ++

i

)

4331 template

<

typename

T>

4342  unsigned

bitval = *

buf

& 1;

4364  unsigned len

= (*

buf

>> 3);

4366  for

(;

i

<

len

; ++

i

)

4392 template

<

typename

T>

4395

*

buf

= (

T

)((*

buf

& 6u) + (1u << 3));

4397  T

* pcurr =

buf

+ 1;

4403

*pcurr = (

T

)(curr - 1);

4413  for

(

i

= 1;

i

<

len

; ++

i

)

4416  if

(curr ==

prev

+ 1)

4425

*pcurr++ = (

T

)(curr-1);

4436  unsigned

gap_len = unsigned(pcurr -

buf

);

4437  BM_ASSERT

(gap_len == ((gap_len << 3) >> 3));

4439

*

buf

= (

T

)((*

buf

& 7) + (gap_len << 3));

4453 template

<

typename

T>

4456  unsigned

gap_count = 1;

4460  for

(

unsigned i

= 1;

i

<

len

; ++

i

)

4463  if

(curr !=

prev

+ 1)

4485 template

<

typename

T>

4500  unsigned val

=

buf

[gap_idx] + 1;

4520  const unsigned

maskFF = ~0u;

4527

*dest |= (1u << bitpos);

4532  unsigned

mask_r = maskFF << bitpos;

4533  if

(

unsigned

right_margin = bitpos + bitcount; right_margin < 32)

4535

*dest |= (maskFF >> (32 - right_margin)) & mask_r;

4539

bitcount -= 32 - bitpos;

4541  for

( ;bitcount >= 64; bitcount-=64, dest+=2)

4542

dest[0] = dest[1] = maskFF;

4544

{ *dest++ = maskFF; bitcount -= 32; }

4546

*dest |= (maskFF >> (32 - bitcount));

4567

*dest &= ~(bitcount << bitpos);

4570  const unsigned

maskFF = ~0u;

4573  unsigned

mask_r = maskFF << bitpos;

4574  if

(

unsigned

right_margin = bitpos + bitcount; right_margin < 32)

4576

*dest &= ~((maskFF >> (32 - right_margin)) & mask_r);

4580

bitcount -= 32 - bitpos;

4582  for

( ;bitcount >= 64; bitcount-=64, dest+=2)

4583

dest[0] = dest[1] = 0u;

4586

*dest++ = 0u; bitcount -= 32;

4589

*dest &= ~(maskFF >> (32 - bitcount));

4614

*word ^= unsigned(1 << nbit);

4620  unsigned

right_margin = nbit + bitcount;

4625  if

(right_margin < 32)

4629  unsigned mask

= mask_r & mask_l;

4634

bitcount -= 32 - nbit;

4637  for

( ;bitcount >= 64; bitcount-=64, word+=2)

4639

word[0] ^= ~0u; word[1] ^= ~0u;

4643

*word++ ^= ~0u; bitcount -= 32;

4659 template

<

typename

T>

4665  const T

* pend = pcurr + (*pcurr >> 3);

4671  for

(pcurr += 2; pcurr <= pend; pcurr += 2)

4690 template

<

typename

T>

4697  const unsigned len

= (*pcurr >> 3);

4716  unsigned

found_pos =

bm::gap_bfind

(pbuf, start_pos, &is_set);

4719

found_pos += !is_set;

4720

pcurr = pbuf + found_pos;

4722  BM_ASSERT

(pcurr > pend || *pcurr >= start_pos);

4726  for

(; pcurr <= pend; pcurr += 2)

4727  if

(*pcurr >= start_pos)

4735  for

(

T prev

; pcurr <= pend; pcurr += 2)

4739  unsigned

pos = 1u +

prev

;

4758 template

<

typename

T>

4764  const T

* pend = pcurr + (*pcurr >> 3);

4770  for

(pcurr += 2; pcurr <= pend; pcurr += 2)

4786 template

<

typename

T>

4792  const T

* pend = pcurr +

len

;

4803  for

(; pcurr <= pend; )

4806

pos = 1u + pcurr[-1];

4807

bc = *pcurr - pcurr[-1];

4821 template

<

typename

T>

4825  unsigned len

= (*pcurr >> 3);

4837 template

<

typename

T>

4843  const T

* pend = pcurr + (*pcurr >> 3);

4853  for

(; pcurr <= pend; )

4856

pos = 1u + pcurr[-1];

4857

bc = *pcurr - pcurr[-1];

4874 template

<

typename

T>

4882  const unsigned len

= (*pcurr >> 3);

4901  unsigned

found_pos =

bm::gap_bfind

(pbuf, start_pos, &is_set);

4904

found_pos += is_set;

4905

pcurr = pbuf + found_pos;

4907  BM_ASSERT

(pcurr > pend || *pcurr >= start_pos);

4911  for

(; pcurr <= pend; pcurr += 2)

4912  if

(*pcurr >= start_pos)

4921  for

(

T prev

; pcurr <= pend; pcurr += 2)

4925  unsigned

pos = 1u +

prev

;

4945 template

<

typename

T>

4950  const T

* pend = pcurr + (*pcurr >> 3);

4957  for

(pcurr +=2 ;pcurr <= pend; pcurr += 2)

4973 template

<

typename

T>

4979  const T

* pend = pcurr + (*pcurr >> 3);

4986  for

(pcurr +=2 ;!

count

&& pcurr <= pend; pcurr += 2)

5003 template

<

typename

T>

5009  const T

* pcurr =

buf

;

5010  const T

* pend = pcurr + (*pcurr >> 3);

5022  for

(;pcurr <= pend; pcurr+=2)

5038 template

<

typename

T>

5044  const T

* pcurr =

buf

;

5045  const T

* pend = pcurr + (*pcurr >> 3);

5059  for

(; !

count

&& pcurr <= pend; pcurr+=2)

5076 template

<

typename

T>

5082  const T

* pcurr =

buf

;

5083  const T

* pend = pcurr + (*pcurr >> 3);

5086  unsigned

bitval = *

buf

& 1;

5094  for

(bitval^=1, ++pcurr; pcurr <= pend; bitval^=1, ++pcurr)

5096  T prev

= (

T

)(*(pcurr-1)+1);

5100

c = (*pcurr -

prev

+ 1) - c;

5114 template

<

typename

T>

5120  const T

* pcurr =

buf

;

5121  const T

* pend = pcurr + (*pcurr >> 3);

5124  unsigned

bitval = *

buf

& 1;

5130  for

(bitval^=1, ++pcurr; !

count

&& pcurr <= pend; bitval^=1, ++pcurr)

5132  T prev

= (

T

)(*(pcurr-1)+1);

5136

c = (*pcurr -

prev

+ 1) - c;

5152 template

<

typename

T>

5157  const T

* pcurr =

buf

;

5158  const T

* pend = pcurr + (*pcurr >> 3);

5161  unsigned

bitval = *

buf

& 1;

5165  for

(bitval^=1, ++pcurr; pcurr <= pend; bitval^=1, ++pcurr)

5167  T prev

= (

T

)(*(pcurr-1)+1);

5169

bitval ? (*pcurr -

prev

+ 1)

5184 template

<

typename

T>

5222 template

<

typename

T>

5247 template

<

typename

T>

5252  if

(

buf

[1] == set_max - 1)

5268 template

<

typename

T>

5271  unsigned

end = *

buf

>> 3;

5273  const T

* pcurr =

buf

;

5274  const T

* pend = pcurr + (*pcurr >> 3);

5282  while

(pcurr <= pend)

5304

*(++

buf

) = (

T

)(set_max - 1);

5329  if

(to == set_max - 1)

5337  buf

[2] = (

T

)(set_max - 1);

5338  buf

[0] = (

T

)((*

buf

& 6u) + (gap_len << 3) +

value

);

5345  if

(to == set_max - 1)

5348  buf

[1] = (

T

)(from - 1);

5349  buf

[2] = (

T

)(set_max - 1);

5354  buf

[1] = (

T

) (from - 1);

5356  buf

[3] = (

T

)(set_max - 1);

5358  buf

[0] = (

T

)((*

buf

& 6u) + (gap_len << 3) +

value

);

5375 #pragma GCC diagnostic push 5376 #pragma GCC diagnostic ignored "-Wconversion" 5386 template

<

typename

T>

5392

*

buf

= (

T

)(((level & 3) << 1) | (*

buf

& 1) | (*

buf

& ~7));

5395 #pragma GCC diagnostic pop 5408 template

<

typename

T>

5411  if

(

len

<=

unsigned

(glevel_len[0]-4))

return

0;

5412  if

(

len

<=

unsigned

(glevel_len[1]-4))

return

1;

5413  if

(

len

<=

unsigned

(glevel_len[2]-4))

return

2;

5414  if

(

len

<=

unsigned

(glevel_len[3]-4))

return

3;

5429 template

<

typename

T>

5435  return

capacity -

len

;

5447 template

<

typename

T>

5451  const T

* pend1 = buf1 +

len

;

5458  return

(w1 & diff & -diff) ? 1 : -1;

5459

}

while

(buf1 < pend1);

5478 #ifdef VECT_BIT_FIND_DIFF 5498

*pos = unsigned(idx + (

i

* 8u *

unsigned

(

sizeof

(

bm::wordop_t

))));

5510

*pos = unsigned(idx + (

i

* 8u *

sizeof

(

bm::word_t

)));

5541  unsigned

bitval = (*block) & 1u;

5544  unsigned

bit_idx = 0;

5548  unsigned val

= *block;

5549  while

(!

val

||

val

== ~0u)

5551  if

(bitval !=

unsigned

(

bool

(

val

)))

5555  BM_ASSERT

((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));

5558

bit_idx += unsigned(

sizeof

(*block) * 8);

5559  if

(++block >= block_end)

5566  unsigned

bits_consumed = 0;

5570  if

(bitval != (

val

& 1u))

5574  BM_ASSERT

((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));

5584

bits_consumed += tz;

5590  if

(bits_consumed < 32u)

5594

bit_idx += 32u - bits_consumed;

5595  BM_ASSERT

((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));

5602

}

while

(++block < block_end);

5606  unsigned len

= (unsigned)(pcurr - dest);

5622 #if defined(VECT_BIT_TO_GAP) 5634 template

<

class

T,

class

F>

5637  const T

* pcurr =

buf

;

5638  const T

* pend = pcurr + (*pcurr >> 3);

5648  unsigned

to = *pcurr;

5649  for

(

unsigned i

= 0;

i

<= to; ++

i

)

5662  while

(pcurr <= pend)

5664  unsigned

from = *(pcurr-1)+1;

5665  unsigned

to = *pcurr;

5668

func(from -

prev

+ first_inc);

5676  for

(

unsigned i

= from+1;

i

<= to; ++

i

)

5689 template

<

typename

D,

typename

T>

5696  const T

* pend = pcurr + (*pcurr >> 3);

5701  int

bitval = (*buf) & 1;

5707  if

(

unsigned

(*pcurr + 1) >= dest_len)

5711  for

(

T i

= 0; ;++

i

)

5714  if

(

i

== to)

break

;

5720  while

(pcurr <= pend)

5722  unsigned

pending = *pcurr - *(pcurr-1);

5723  if

(pending >= dest_len)

5725

dest_len -= pending;

5726  T

from = (

T

)(*(pcurr-1)+1);

5728  for

(

T i

= from; ;++

i

)

5731  if

(

i

== to)

break

;

5735  return

(

D

) (dest_curr - dest);

5757  #if defined(BM_USE_GCC_BUILD) 5758  count

+= unsigned(__builtin_popcountll(x) + __builtin_popcountll(y)

5759

+ __builtin_popcountll(u) + __builtin_popcountll(v));

5771

}

while

(block < block_end);

5782

}

while

(block < block_end);

5821 #ifdef VECT_BIT_COUNT_DIGEST 5844  #if defined(BM_USE_GCC_BUILD) 5845  count

+= unsigned(__builtin_popcountll(x) + __builtin_popcountll(y)

5846

+ __builtin_popcountll(u) + __builtin_popcountll(v));

5871

}

while

(blk < blk_end);

5899  count

-= (w >> ((

sizeof

(w) * 8) - 1));

5912  unsigned

gap_count = 1;

5917  const int

w_shift =

int

(

sizeof

(w) * 8 - 1);

5920

gap_count -= (w_prev = (w0 >> w_shift));

5923  for

(++block; block < block_end; ++block)

5929

gap_count -= !w_prev;

5937

gap_count -= (w0 >> w_shift);

5938

gap_count -= !(w_prev ^ w_l);

5940

w_prev = (w0 >> w_shift);

5954  unsigned

gap_count = 1;

5960  const int

w_shift =

int

(

sizeof

(w) * 8 - 1);

5963

gap_count -= unsigned(w_prev = (w0 >> w_shift));

5966  for

(++block; block < block_end; ++block)

5972

gap_count -= !w_prev;

5980

gap_count -= unsigned(w0 >> w_shift);

5981

gap_count -= !(w_prev ^ w_l);

5982

w_prev = (w0 >> w_shift);

6006  #ifdef VECT_BLOCK_CHANGE_BC 6033 #if defined(VECT_BLOCK_CHANGE) 6056  unsigned

nbit, bitcount, temp;

6061  return

(*word >> nbit) & 1u;

6065  unsigned

right_margin = nbit + right - left;

6066  if

(right_margin < 32)

6070  unsigned mask

= mask_r & mask_l;

6075

temp = *word & mask_r;

6078

bitcount = (right - left + 1u) - (32 - nbit);

6083

bitcount = right - left + 1u;

6090  #if defined(BM64OPT) || defined(BM64_SSE4) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 6092  for

( ;bitcount >= 128; bitcount-=128, word+=4)

6096  if

((w64_0 ^ maskFF64) | (w64_1 ^ maskFF64))

6100  for

( ;bitcount >= 128; bitcount-=128, word+=4)

6102  bm::word_t

m = (word[0] != maskFF) || (word[1] != maskFF) |

6103

(word[2] != maskFF) || (word[3] != maskFF);

6109  for

( ;bitcount >= 32; bitcount-=32, ++word)

6111  if

(*word != maskFF)

6118

temp = *word & mask_l;

6137 template

<

bool

LWA,

bool

RWA>

6145  unsigned

nword, nbit, bitcount,

count

, right_margin;

6149  return

(*block >> nbit) & 1u;

6151

bitcount = 1u + (right_margin = (right - left));

6160

right_margin += nbit;

6162  if

(right_margin < 32)

6168

bitcount -= 32 - nbit;

6175  #if defined(BM64_SSE4) || defined(BM64_AVX2) || defined(BM64_AVX512) 6176  for

( ;bitcount >= 128; bitcount-=128)

6185  for

( ;bitcount >= 64; bitcount-=64)

6197  for

( ;bitcount >= 32; bitcount-=32)

6232  unsigned

bitcount = right + 1;

6235  #if defined(BMAVX2OPT) || defined(BMAVX512OPT) 6238

__m256i

cnt

= _mm256_setzero_si256();

6241  for

( ;bitcount >= 256; bitcount -= 256)

6243  const

__m256i* src = (__m256i*)block;

6244

__m256i xmm256 = _mm256_load_si256(src);

6246  cnt

= _mm256_add_epi64(

cnt

, bc);

6251  count

+= (unsigned)(cnt64[0] + cnt64[1] + cnt64[2] + cnt64[3]);

6254  for

( ;bitcount >= 64; bitcount -= 64)

6286

block[

i

] = (block[

i

] << 1) | (block[

i

+ 1] >> 31);

6300  const unsigned

unroll_factor = 4;

6306

w0 = block[

i

+ 1] >> 31;

6307

w1 = block[

i

+ 2] >> 31;

6308

w2 = block[

i

+ 3] >> 31;

6309

w3 = block[

i

+ 4] >> 31;

6311

block[0 +

i

] = (block[0 +

i

] << 1) | w0;

6312

block[1 +

i

] = (block[1 +

i

] << 1) | w1;

6313

block[2 +

i

] = (block[2 +

i

] << 1) | w2;

6314

block[3 +

i

] = (block[3 +

i

] << 1) | w3;

6316

block[

i

] = (block[

i

] << 1) | (block[

i

+ 1] >> 31);

6317

block[

i

+ 1] = (block[

i

+ 1] << 1) | (block[

i

+ 2] >> 31);

6318

block[

i

+ 2] = (block[

i

+ 2] << 1) | (block[

i

+ 3] >> 31);

6351

block[nword] = w | (unsigned(

value

) << nbit) | wl;

6363

w = (w << 1u) | co_flag;

6394

acc |= w = (w << 1u) | co_flag;

6418 #if defined(BM64OPT) 6430

acc0 |= w = (w << 1u) | co_flag;

6431

b_u->w64[

i

++] = w;

6436

acc1 |= w = (w << 1u) | co_flag;

6441

*empty_acc =

bool

(acc0 | acc1);

6465  #if defined(VECT_SHIFT_R1) 6495

acc |= w = (w >> 1u) | (co_flag << 31u);

6523

w0 = block[

i

]; w1 = block[

i

-1];

6525

acc |= w0 = (w0 >> 1u) | (co_flag << 31u);

6529

acc |= w1 = (w1 >> 1u) | (co_flag << 31u);

6534

w0 = block[

i

]; w1 = block[

i

-1];

6536

acc |= w0 = (w0 >> 1u) | (co_flag << 31u);

6540

acc |= w1 = (w1 >> 1u) | (co_flag << 31u);

6565  #if defined(VECT_SHIFT_L1) 6605

w = (w >> 1u) | (co_flag << 31u);

6617

w |= wl | (co_flag << 31u);

6622

block[nword] = (block[nword] >> 1u) | (co_flag << 31u);

6657  for

(; di < 64; ++di)

6670

w = (w << 1u) | co_flag;

6671

acc |= block[

i

] = w & mask_block[

i

];

6687

block[d_base] = co_flag & mask_block[d_base];

6719  #if defined(VECT_SHIFT_R1_AND) 6741  unsigned

nbit = left;

6749  return

(*word >> nbit) & 1;

6752  unsigned

bitcount = right - left + 1;

6756  unsigned

right_margin = nbit + (right - left);

6757  if

(right_margin < 32)

6761  unsigned mask

= mask_r & mask_l;

6762  return

*word &

mask

;

6767

acc = *word & mask_r;

6770

bitcount -= 32 - nbit;

6778  for

( ;bitcount >= 128; bitcount-=128, word+=4)

6780

acc = word[0] | word[1] | word[2] | word[3];

6786  for

( ;bitcount >= 32; bitcount -= 32)

6794

acc |= (*word) & mask_l;

6804 template

<

typename

T>

6814

start[0] = ~start[0];

6815

start[1] = ~start[1];

6816

start[2] = ~start[2];

6817

start[3] = ~start[3];

6819

}

while

(start < end);

6831 #if defined(VECT_IS_ONE_BLOCK) 6839

start[0] & start[1] & start[2] & start[3];

6843

}

while

(start < end);

6884  bool

is_left, is_right, all_one;

6897  if

(is_left ==

false

)

6901  if

(is_right ==

false

)

6934

w &= (1u << bit_pos);

6949

w = (~block[nword]) >> bit_pos;

6954

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

)))-1);

6964

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

)))-1);

7030

w &= (1u << bit_pos);

7046

w = (~block[nword]) & mask_l;

7050

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

)))+1);

7056  for

(--nword;

true

; --nword)

7062

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

)))+1);

7094

w &= (1u << bit_pos);

7097

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

))));

7109

w = block[nword] & mask_l;

7113

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

))));

7119  for

(--nword;

true

; --nword)

7126

unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

))));

7155  if

(

b

&& *found_nbit == 0)

7166  if

(

b

&& *found_nbit == 0)

7194

*found_nbit = nbit_from;

7271

bm::gap_buff_op<bm::gap_word_t, bm::and_func>(

7272

tmp_buf, vect1, 0, vect2, 0, dsize);

7294  return

gap_buff_any_op<bm::gap_word_t, bm::and_func>(vect1, 0, vect2, 0);

7311  return

bm::gap_buff_count_op<bm::gap_word_t, bm::and_func>(vect1, vect2);

7338

bm::gap_buff_op<bm::gap_word_t, bm::xor_func>(

7339

tmp_buf, vect1, 0, vect2, 0, dsize);

7376  return

gap_buff_any_op<bm::gap_word_t, bm::xor_func>(vect1, 0, vect2, 0);

7392  return

bm::gap_buff_count_op<bm::gap_word_t, bm::xor_func>(vect1, vect2);

7419

bm::gap_buff_op<bm::gap_word_t, bm::and_func>(tmp_buf, vect1, 1, vect2, 1, dsize);

7437  return

gap_buff_count_op<bm::gap_word_t, bm::or_func>(vect1, vect2);

7465

bm::gap_buff_op<bm::gap_word_t, bm::and_func>(

7466

tmp_buf, vect1, 0, vect2, 1, dsize);

7490

bm::gap_buff_any_op<bm::gap_word_t, bm::and_func>(

7491

vect1, 0, vect2, 1);

7508  return

bm::gap_buff_count_op<bm::gap_word_t, bm::sub_func>(vect1, vect2);

7546 #ifdef VECT_COPY_BLOCK_UNALIGN 7567 #ifdef VECT_STREAM_BLOCK 7585 #ifdef VECT_STREAM_BLOCK_UNALIGN 7620  for

(

unsigned i

= 0;

i

< arr_sz;

i

+=4)

7622

acc |= (dst_u->w64[

i

] &= src_u->w64[

i

]) |

7623

(dst_u->w64[

i

+1] &= src_u->w64[

i

+1]) |

7624

(dst_u->w64[

i

+2] &= src_u->w64[

i

+2]) |

7625

(dst_u->w64[

i

+3] &= src_u->w64[

i

+3]);

7661  #if defined(VECT_AND_DIGEST) 7664

digest &= ~(

mask

<< wave);

7673

acc |= dst_u->w64[j+0] &= src_u->w64[j+0];

7674

acc |= dst_u->w64[j+1] &= src_u->w64[j+1];

7675

acc |= dst_u->w64[j+2] &= src_u->w64[j+2];

7676

acc |= dst_u->w64[j+3] &= src_u->w64[j+3];

7681

digest &= ~(

mask

<< wave);

7705  BM_ASSERT

(src0 && src1 && src2 && src3);

7716 #if defined(VECT_AND_DIGEST_5WAY) 7717  bool

all_zero =

VECT_AND_DIGEST_5WAY

(&dst[off], &src0[off], &src1[off], &src2[off], &src3[off]);

7719

digest &= ~(

mask

<< wave);

7731

acc |= dst_u->w64[j + 0] &= src_u0->w64[j + 0] & src_u1->w64[j + 0] & src_u2->w64[j + 0] & src_u3->w64[j + 0];

7732

acc |= dst_u->w64[j + 1] &= src_u0->w64[j + 1] & src_u1->w64[j + 1] & src_u2->w64[j + 1] & src_u3->w64[j + 1];

7733

acc |= dst_u->w64[j + 2] &= src_u0->w64[j + 2] & src_u1->w64[j + 2] & src_u2->w64[j + 2] & src_u3->w64[j + 2];

7734

acc |= dst_u->w64[j + 3] &= src_u0->w64[j + 3] & src_u1->w64[j + 3] & src_u2->w64[j + 3] & src_u3->w64[j + 3];

7738

digest &= ~(

mask

<< wave);

7778  #if defined(VECT_AND_DIGEST_3WAY) 7781

digest &= ~(

mask

<< wave);

7792

acc |= dst_u->w64[j] &= src_u1->w64[j] & src_u2->w64[j];

7793

acc |= dst_u->w64[j+1] &= src_u1->w64[j+1] & src_u2->w64[j+1];

7794

acc |= dst_u->w64[j+2] &= src_u1->w64[j+2] & src_u2->w64[j+2];

7795

acc |= dst_u->w64[j+3] &= src_u1->w64[j+3] & src_u2->w64[j+3];

7800

digest &= ~(

mask

<< wave);

7843  #if defined(VECT_AND_DIGEST_2WAY) 7846

digest &= ~(

mask

<< wave);

7857

acc |= dst_u->w64[j] = src_u1->w64[j] & src_u2->w64[j];

7858

acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & src_u2->w64[j+1];

7859

acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & src_u2->w64[j+2];

7860

acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & src_u2->w64[j+3];

7865

digest &= ~(

mask

<< wave);

7895  for

(

unsigned i

= 0;

i

< 64; ++

i

)

7900  #if defined(VECT_AND_DIGEST_2WAY) 7915

acc |= dst_u->w64[j] = src_u1->w64[j] & src_u2->w64[j];

7916

acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & src_u2->w64[j+1];

7917

acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & src_u2->w64[j+2];

7918

acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & src_u2->w64[j+3];

7929  #if defined(VECT_BLOCK_SET_DIGEST) 7934

dst[off] = dst[off+1] = dst[off+2] = dst[off+3] = 0u;

7976  #if defined(VECT_AND_OR_DIGEST_2WAY) 7980

digest &= ~(

mask

<< wave);

7993

acc |= dst_u->w64[j+0] |= src_u1->w64[j+0] & src_u2->w64[j+0];

7994

acc |= dst_u->w64[j+1] |= src_u1->w64[j+1] & src_u2->w64[j+1];

7995

acc |= dst_u->w64[j+2] |= src_u1->w64[j+2] & src_u2->w64[j+2];

7996

acc |= dst_u->w64[j+3] |= src_u1->w64[j+3] & src_u2->w64[j+3];

8001

digest &= ~(

mask

<< wave);

8042

}

while

(b1 < b1_end);

8052

}

while

(src1 < src1_end);

8076  count

= (src1[0] & src2[0]) |

8077

(src1[1] & src2[1]) |

8078

(src1[2] & src2[2]) |

8079

(src1[3] & src2[3]);

8081

}

while

((src1 < src1_end) && !

count

);

8119

}

while

(b1 < b1_end);

8129

}

while

(src1 < src1_end);

8153  count

= (src1[0] ^ src2[0]) |

8154

(src1[1] ^ src2[1]) |

8155

(src1[2] ^ src2[2]) |

8156

(src1[3] ^ src2[3]);

8158

}

while

(!

count

&& (src1 < src1_end));

8192

}

while

(b1 < b1_end);

8202

}

while

(src1 < src1_end);

8226  count

= (src1[0] & ~src2[0]) |

8227

(src1[1] & ~src2[1]) |

8228

(src1[2] & ~src2[2]) |

8229

(src1[3] & ~src2[3]);

8231

}

while

((src1 < src1_end) && (

count

== 0));

8267

}

while

(b1 < b1_end);

8277

}

while

(src1 < src1_end);

8300  count

= (src1[0] | src2[0]) |

8301

(src1[1] | src2[1]) |

8302

(src1[2] | src2[2]) |

8303

(src1[3] | src2[3]);

8306

}

while

(!

count

&& (src1 < src1_end));

8598

acc &= (dst_ptr[0] |= wrd_ptr[0]);

8599

acc &= (dst_ptr[1] |= wrd_ptr[1]);

8600

acc &= (dst_ptr[2] |= wrd_ptr[2]);

8601

acc &= (dst_ptr[3] |= wrd_ptr[3]);

8603

dst_ptr+=4;wrd_ptr+=4;

8605

}

while

(wrd_ptr < wrd_end);

8606  return

acc == not_acc;

8636

acc &= (dst_ptr[0] = wrd_ptr1[0] | wrd_ptr2[0]);

8637

acc &= (dst_ptr[1] = wrd_ptr1[1] | wrd_ptr2[1]);

8638

acc &= (dst_ptr[2] = wrd_ptr1[2] | wrd_ptr2[2]);

8639

acc &= (dst_ptr[3] = wrd_ptr1[3] | wrd_ptr2[3]);

8641

dst_ptr+=4; wrd_ptr1+=4; wrd_ptr2+=4;

8643

}

while

(wrd_ptr1 < wrd_end1);

8644  return

acc == not_acc;

8674

acc |= (dst_ptr[0] = wrd_ptr1[0] ^ wrd_ptr2[0]);

8675

acc |= (dst_ptr[1] = wrd_ptr1[1] ^ wrd_ptr2[1]);

8676

acc |= (dst_ptr[2] = wrd_ptr1[2] ^ wrd_ptr2[2]);

8677

acc |= (dst_ptr[3] = wrd_ptr1[3] ^ wrd_ptr2[3]);

8679

dst_ptr+=4; wrd_ptr1+=4; wrd_ptr2+=4;

8681

}

while

(wrd_ptr1 < wrd_end1);

8716

acc &= (dst_ptr[0] |= wrd_ptr1[0] | wrd_ptr2[0]);

8717

acc &= (dst_ptr[1] |= wrd_ptr1[1] | wrd_ptr2[1]);

8718

acc &= (dst_ptr[2] |= wrd_ptr1[2] | wrd_ptr2[2]);

8719

acc &= (dst_ptr[3] |= wrd_ptr1[3] | wrd_ptr2[3]);

8721

dst_ptr+=4; wrd_ptr1+=4;wrd_ptr2+=4;

8723

}

while

(wrd_ptr1 < wrd_end1);

8724  return

acc == not_acc;

8764

acc &= (dst_ptr[0] |= wrd_ptr1[0] | wrd_ptr2[0] | wrd_ptr3[0] | wrd_ptr4[0]);

8765

acc &= (dst_ptr[1] |= wrd_ptr1[1] | wrd_ptr2[1] | wrd_ptr3[1] | wrd_ptr4[1]);

8766

acc &= (dst_ptr[2] |= wrd_ptr1[2] | wrd_ptr2[2] | wrd_ptr3[2] | wrd_ptr4[2]);

8767

acc &= (dst_ptr[3] |= wrd_ptr1[3] | wrd_ptr2[3] | wrd_ptr3[3] | wrd_ptr4[3]);

8770

wrd_ptr1+=4;wrd_ptr2+=4;wrd_ptr3+=4;wrd_ptr4+=4;

8772

}

while

(wrd_ptr1 < wrd_end1);

8773  return

acc == not_acc;

8866  for

(

unsigned i

= 0;

i

< arr_sz;

i

+=4)

8868

acc |= (dst_u->w64[

i

] &= ~src_u->w64[

i

]) |

8869

(dst_u->w64[

i

+1] &= ~src_u->w64[

i

+1]) |

8870

(dst_u->w64[

i

+2] &= ~src_u->w64[

i

+2]) |

8871

(dst_u->w64[

i

+3] &= ~src_u->w64[

i

+3]);

8908  #if defined(VECT_SUB_DIGEST) 8911

digest &= ~(

mask

<< wave);

8920

acc |= dst_u->w64[j+0] &= ~src_u->w64[j+0];

8921

acc |= dst_u->w64[j+1] &= ~src_u->w64[j+1];

8922

acc |= dst_u->w64[j+2] &= ~src_u->w64[j+2];

8923

acc |= dst_u->w64[j+3] &= ~src_u->w64[j+3];

8928

digest &= ~(

mask

<< wave);

8969  #if defined(VECT_SUB_DIGEST_2WAY) 8972

digest &= ~(

mask

<< wave);

8985

acc |= dst_u->w64[j+0] = src_u1->w64[j+0] & ~src_u2->w64[j+0];

8986

acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & ~src_u2->w64[j+1];

8987

acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & ~src_u2->w64[j+2];

8988

acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & ~src_u2->w64[j+3];

8993

digest &= ~(

mask

<< wave);

9015  BM_ASSERT

(src0 && src1 && src2 && src3);

9027 #if defined(VECT_SUB_DIGEST_5WAY) 9028  bool

all_zero =

VECT_SUB_DIGEST_5WAY

(&dst[off], &src0[off], &src1[off], &src2[off], &src3[off]);

9030

digest &= ~(

mask

<< wave);

9042

acc |= dst_u->w64[j + 0] &= ~src_u0->w64[j + 0] & ~src_u1->w64[j + 0] & ~src_u2->w64[j + 0] & ~src_u3->w64[j + 0];

9043

acc |= dst_u->w64[j + 1] &= ~src_u0->w64[j + 1] & ~src_u1->w64[j + 1] & ~src_u2->w64[j + 1] & ~src_u3->w64[j + 1];

9044

acc |= dst_u->w64[j + 2] &= ~src_u0->w64[j + 2] & ~src_u1->w64[j + 2] & ~src_u2->w64[j + 2] & ~src_u3->w64[j + 2];

9045

acc |= dst_u->w64[j + 3] &= ~src_u0->w64[j + 3] & ~src_u1->w64[j + 3] & ~src_u2->w64[j + 3] & ~src_u3->w64[j + 3];

9050

digest &= ~(

mask

<< wave);

9082 #if defined(VECT_SUB_DIGEST_3WAY) 9085

digest &= ~(

mask

<< wave);

9095

acc |= dst_u->w64[j + 0] &= ~src_u0->w64[j + 0] & ~src_u1->w64[j + 0];

9096

acc |= dst_u->w64[j + 1] &= ~src_u0->w64[j + 1] & ~src_u1->w64[j + 1];

9097

acc |= dst_u->w64[j + 2] &= ~src_u0->w64[j + 2] & ~src_u1->w64[j + 2];

9098

acc |= dst_u->w64[j + 3] &= ~src_u0->w64[j + 3] & ~src_u1->w64[j + 3];

9103

digest &= ~(

mask

<< wave);

9198  for

(

unsigned i

= 0;

i

< arr_sz;

i

+=4)

9200

acc |= dst_u->w64[

i

] ^= src_u->w64[

i

];

9201

acc |= dst_u->w64[

i

+1] ^= src_u->w64[

i

+1];

9202

acc |= dst_u->w64[

i

+2] ^= src_u->w64[

i

+2];

9203

acc |= dst_u->w64[

i

+3] ^= src_u->w64[

i

+3];

9235

dst_ptr+=4; wrd_ptr+=4;

9236

}

while

(wrd_ptr < wrd_end);

9257  if

(src == dst)

return

0;

9263  if

(!src)

return

dst;

9269  if

(!src)

return

dst;

9353  const T

* blk_end = blk + data_size - 2;

9358  const T

* blk_j = blk + 1;

9359  for

(; blk_j < blk_end; ++blk_j)

9369  const T

* blk_j = blk + 1;

9370  for

( ; blk_j < blk_end; ++blk_j)

9374  if

(blk_j[1] | blk_j[2])

9384  count

+= unsigned(blk_j - blk) * unsigned(

sizeof

(

T

));

9389  while

(blk < blk_end);

9390  return count

+ unsigned(2 *

sizeof

(

T

));

9415

w &= (1u << bit_pos);

9421

w = block[nword] >> bit_pos;

9426

*pos = unsigned(bit_pos + (nword * 8u *

unsigned

(

sizeof

(

bm::word_t

))));

9436

*pos = unsigned(bit_pos + (

i

* 8u *

unsigned

(

sizeof

(

bm::word_t

))));

9470

*

last

= unsigned(idx + (

i

* 8u *

unsigned

(

sizeof

(

bm::word_t

))));

9496 #ifdef VECT_BIT_FIND_FIRST 9505

*pos = unsigned(idx + (

i

* 8u *

unsigned

(

sizeof

(

bm::word_t

))));

9537 #ifdef VECT_BIT_FIND_FIRST 9545  unsigned

base =

i

* 8u * unsigned(

sizeof

(

bm::word_t

));

9555

w64 = block[

i

] | block[

i

+1];

9558  unsigned

base =

i

* 8u * unsigned(

sizeof

(

bm::word_t

));

9598 #if defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 9604  const unsigned cnt

=

i

+ 4;

9613  for

(++

i

;

i

<

cnt

; ++

i

)

9620

}

while

(++

i

<

cnt

);

9633  if

(

auto

w = block[

i

])

9663 template

<

typename

SIZE_TYPE>

9675  unsigned

pos = nbit_from;

9685

rank -= bc; pos += unsigned(32u - nbit);

9691

nbit_pos = pos + idx;

9696  #if defined(BM64OPT) || defined(BM64_SSE4) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 9706

nbit_pos = pos + idx;

9721

rank -= bc; pos += 32u;

9725

nbit_pos = pos + idx;

9744 template

<

typename

SIZE_TYPE>

9770  unsigned

total_possible_bitcount,

9778  if

((gap_size < block_size) && (gap_size < arr_size) && (gap_size < inv_arr_size))

9783  if

(arr_size < inv_arr_size)

9785  if

((arr_size < block_size) && (arr_size < gap_size))

9792  if

((inv_arr_size < block_size) && (inv_arr_size < gap_size))

9811 template

<

typename

T>

9816  const bm::id64_t

imask64 = inverted ? ~0ull : 0;

9819

src+=2, bit_idx += unsigned(

sizeof

(*src) * 8 * 2))

9830  return

(

unsigned

)(pcurr - dest);

9834 template

<

typename

T>

9838  for

(

unsigned i

= 1;

i

< sz; ++

i

)

9841  unsigned

d =

arr

[

i

] -

arr

[

i

-1];

9855 template

<

typename

T>

9864  unsigned

bitpos = 0;

9865  unsigned

w = block[nword];

9872  b

= (~w) & (1 << 1);

9875

arr_ex0[ex0_cnt] = 0; ++ex0_cnt;

9880  for

(;

i

<= 65534; ++

i

)

9885  b

= w & (1 << bitpos);

9893  bool

b_prev = w & (1 << bitpos);

9900  bool

b_next = w & (1 << bitpos);

9909

w &= ~(1 << bitpos);

9911

arr_ex0[ex0_cnt] = (

T

)

i

; ++ex0_cnt;

9925

arr_ex0[ex0_cnt] = 0; ++ex0_cnt;

9931  for

(;

i

<= 65534; ++

i

)

9936  b

= w & (1 << bitpos);

9944  bool

b_prev = w & (1 << bitpos);

9951  bool

b_next = w & (1 << bitpos);

9962

arr_ex0[ex0_cnt] = (

T

)

i

; ++ex0_cnt;

9975 template

<

typename

T>

9981  for

(

unsigned

k = 0; k < ex0_cnt; ++k)

10007 template

<

typename

T>

10016  const bm::id64_t

imask64 = inverted ? ~0ull : 0;

10024

src+=2, bit_idx += unsigned(

sizeof

(*src) * 8 * 2))

10032  if

(idx !=

prev

+1)

10036

*pcurr_r++ =

T

(

prev

- rl);

10040

*pcurr_s++ =

T

(idx);

10044  if

(!rl && (pcurr_s != dst_s))

10055

*pcurr_r++ =

T

(

prev

- rl);

10059

s_cnt = (unsigned)(pcurr_s - dst_s);

10060

r_cnt = (unsigned)(pcurr_r - dst_r);

10068 template

<

typename

T>

10076  for

(

unsigned i

= 0;

i

< s_cnt; ++

i

)

10080  for

(

unsigned i

= 0;

i

< r_cnt; ++

i

)

10098  if

(!blk)

return true

;

10122  if

(blk == 0)

return false

;

10142 template

<

typename

T>

10144  const T

* length_end,

10147  BM_ASSERT

(length && length_end && glevel_len);

10149  unsigned

overhead = 0;

10150  for

(;length < length_end; ++length)

10152  unsigned len

= *length;

10155  unsigned

capacity = glevel_len[level];

10157

overhead += capacity -

len

;

10169 template

<

typename

T>

10171  const T

* length_end,

10174  BM_ASSERT

(length && length_end && glevel_len);

10176  size_t

lsize = size_t(length_end - length);

10182  for

(

i

= 0;

i

< lsize; ++

i

)

10184  if

(length[

i

] > max_len)

10185

max_len = length[

i

];

10189

glevel_len[0] =

T

(max_len + 4);

10199  unsigned

min_overhead =

gap_overhead

(length, length_end, glevel_len);

10200  bool

is_improved =

false

;

10208  bool

imp_flag =

false

;

10210  for

(j = 0; j < lsize; ++j)

10212

glevel_len[

i

] =

T

(length[j] + 4);

10213  unsigned

ov =

gap_overhead

(length, length_end, glevel_len);

10214  if

(ov <= min_overhead)

10224

is_improved =

true

;

10228

glevel_len[

i

] = gap_saved_value;

10236  T val

= *glevel_len;

10237  T

* gp = glevel_len;

10238  T

* res = glevel_len;

10255  return

is_improved;

10275  if

(!blk || !arg_blk)

10307  if

(arg_gap != gap)

10418  if

(cnt_ < from_ || cnt_ >

to_

)

10420

++

cnt_

;

return

0;

10438 template

<

class

It1,

class

It2,

class

BinaryOp,

class

Encoder>

10444  for

(

unsigned i

= 0;

i

< block_size; ++

i

)

10449

enc.push_back( w );

10583

&gap_and_to_bitset<bm::gap_word_t>,

10584

&gap_add_to_bitset<bm::gap_word_t>,

10585

&gap_sub_to_bitset<bm::gap_word_t>,

10586

&gap_xor_to_bitset<bm::gap_word_t>,

10641

w0 = w_ptr[0]; w1 = w_ptr[1];

10643 #if defined(BMAVX512OPT) || defined(BMAVX2OPT) || defined(BM64OPT) || defined(BM64_SSE4) 10648

w0 = w_ptr[2]; w1 = w_ptr[3];

10652  #if (defined(__arm__) || defined(__aarch64__)) 10656

w0 = w_ptr[2]; w1 = w_ptr[3];

10658

cnt0 +=

bm::bitscan_bsf

(w1, bits + cnt0, (

unsigned short

)(64+32));

10664

w0 = w_ptr[2]; w1 = w_ptr[3];

10669  return static_cast<unsigned short>

(cnt0);

10672 #if defined (BM64_SSE4) || defined(BM64_AVX2) || defined(BM64_AVX512) 10682  unsigned size

,

unsigned

start,

10685 typedef unsigned

TRGW;

10686 typedef unsigned IDX

;

10687 #if defined(BM64_SSE4) 10690  if

constexpr (

sizeof

(TRGW)==4 &&

sizeof

(

IDX

)==4)

10695 #elif defined(BM64_AVX2) || defined(BM64_AVX512) 10696  if

constexpr (

sizeof

(TRGW)==4 &&

sizeof

(

IDX

)==4)

10712 template

<

typename

TRGW,

typename

IDX,

typename

SZ>

10721  const

SZ

len

= (

size

- start);

10722  const

SZ len_unr =

len

- (

len

% 2);

10724  for

(; k < len_unr; k+=2)

10726  const

SZ base = start + k;

10734  for

(; k <

len

; ++k)

10762  for

(;(start <

size

) &&

10787 #if defined(VECT_ARR_BLOCK_LOOKUP) 10790  for

(;(start <

size

) &&

10825

block[nword] |= (1u << nbit);

10849 #if defined(VECT_SET_BLOCK_BITS) 10854  unsigned n

= idx[start++];

10858

block[nword] |= (1u << nbit);

10859

}

while

(start < stop);

10873  unsigned

& left,

unsigned

& right)

BMNOEXCEPT 10911 #if defined(VECT_LOWER_BOUND_SCAN_U32) 10914  for

(; from <= to; ++from)

10916  if

(

arr

[from] >= target)

10929  unsigned long long

target,

10936  for

(; from <= to; ++from)

10938  if

(

arr

[from] >= target)

10958  const unsigned

linear_cutoff = 32;

10960  unsigned l

= from;

unsigned r

= to;

10961  unsigned

dist =

r

-

l

;

10962  if

(dist < linear_cutoff)

10969  unsigned

mid = (

r

-

l

)/2+

l

;

10970  if

(

arr

[mid] < target)

10975  if

(dist < linear_cutoff)

10989  unsigned long long

target,

10994  const unsigned

linear_cutoff = 32;

10996  unsigned l

= from;

unsigned r

= to;

10997  unsigned

dist =

r

-

l

;

10998  if

(dist < linear_cutoff)

11005  unsigned

mid = (

r

-

l

) / 2 +

l

;

11006  if

(

arr

[mid] < target)

11011  if

(dist < linear_cutoff)

11025 bool find_ptr

(

const void

*

const

* p_arr,

size_t

arr_size,

11029  for

(

size_t i

= 0;

i

< arr_size; ++

i

)

11030  if

(ptr == p_arr[

i

])

11032

*idx =

i

;

return true

;

11050  return

block_idx + base_idx;

11059  return

block_idx + base_idx;

11073  unsigned

md =

arr

[1] -

arr

[0];

11074  for

(

size_t i

= 1;

i

< arr_size; ++

i

)

11077  unsigned

curr =

arr

[

i

];

11102  for

(

size_t i

= 1;

i

< arr_size; ++

i

)

11113 template

<

typename

VT,

typename

SZ>

11116  bool

found =

false

;

11118  for

(SZ

i

= 0;

i

< arr_size; ++

i

)

11123

max_v = v; *found_idx =

i

;

11134 template

<

typename

VT,

typename

SZ>

11137  for

(SZ

i

= 0;

i

< arr_size; ++

i

)

11153 template

<

typename

VT,

typename

SZ>

11157  for

(SZ

i

= 0;

i

< arr_size; ++

i

)

11194  float

bie_bits_per_int,

11202  if

(bc == max_bits)

11208  unsigned

ibc = max_bits - bc;

11214  float

cost_in_bits = float(gc) * bie_bits_per_int;

11215  if

(cost_in_bits >=

float

(max_bits))

11225  float

cost_in_bits = float(bc) * bie_bits_per_int;

11226  if

(cost_in_bits >=

float

(max_bits))

11231

*best_metric = ibc;

11232  float

cost_in_bits = float(ibc) * bie_bits_per_int;

11233  if

(cost_in_bits >=

float

(max_bits))

11239 template

<

typename

T>

11242  unsigned

& win_size,

float

& best_save)

11244  bool

use_wdr =

false

;

11247  for

(

unsigned

w_size = 20; w_size <= 78; w_size += 2)

11258  unsigned

total_windows = (sz + w_size - 1) / w_size;

11259  float

bits_extra = float(total_windows + 1 + 8 + 8);

11260  float

save_per_window = 0.15f * w_size;

11261  float

total_save = save_per_window * wcnt;

11262

total_save -= bits_extra;

11263  if

(total_save > 0.0f)

11267

use_wdr =

true

; win_size = w_size; best_save = total_save;

11270  if

(total_save >= best_save)

11272

win_size = w_size; best_save = total_save;

11300 template

<

typename

T>

11303  T

temp = *

a

; *

a

= *

b

; *

b

= temp;

11309 template

<

typename

T>

11322  while

(

arr

[j] >

arr

[pivot])

11353  unsigned

arr_idx = idx >> 1;

11356  unsigned char

old_val =

arr

[arr_idx];

11358  arr

[arr_idx] = (

unsigned

char)(old_val | (v << 4));

11362  unsigned char

old_val =

arr

[arr_idx];

11364  arr

[arr_idx] = (

unsigned

char)(old_val | (v & 0xF));

11380  unsigned char

v =

arr

[idx >> 1];

11381

v >>= (idx & 1) * 4;

11411  return

(ptr.i16[1] == 0);

11413  bm::id64_t r

= (ptr.i16[1] == v) | (ptr.i16[2] == v) | (ptr.i16[3] == v);

ncbi::TMaskedQueryRegions mask

#define VECT_STREAM_BLOCK_UNALIGN(dst, src)

#define VECT_COPY_BLOCK_UNALIGN(dst, src)

#define VECT_SET_BLOCK(dst, value)

#define VECT_BITCOUNT_OR(first, last, mask)

#define VECT_BIT_FIND_DIFF(src1, src2, pos)

#define VECT_AND_DIGEST_5WAY(dst, src1, src2, src3, src4)

#define VECT_OR_BLOCK_5WAY(dst, src1, src2, src3, src4)

#define VECT_BIT_FIND_FIRST(src1, off, pos)

#define VECT_COPY_BLOCK(dst, src)

#define VECT_SUB_DIGEST_5WAY(dst, src1, src2, src3, src4)

#define BM_AVX2_POPCNT_PROLOG

#define VECT_BITCOUNT_AND(first, last, mask)

#define VECT_SHIFT_R1(b, acc, co)

#define VECT_XOR_BLOCK_2WAY(dst, src1, src2)

#define VECT_IS_ONE_BLOCK(dst)

#define VECT_STREAM_BLOCK(dst, src)

#define VECT_OR_BLOCK(dst, src)

#define VECT_SHIFT_R1_AND(b, co, m, digest)

#define VECT_SUB_BLOCK(dst, src)

#define VECT_GAP_TEST(buf, pos)

#define VECT_IS_ZERO_BLOCK(dst)

#define VECT_BIT_TO_GAP(dest, src, dest_len)

#define VECT_SUB_DIGEST_2WAY(dst, src1, src2)

#define VECT_XOR_BLOCK(dst, src)

#define VECT_IS_DIGEST_ZERO(start)

#define VECT_ANDNOT_ARR_2_MASK(dst, src, src_end, mask)

#define VECT_BLOCK_CHANGE_BC(block, gc, bc)

#define VECT_BIT_COUNT_DIGEST(blk, d)

#define VECT_SHIFT_L1(b, acc, co)

#define VECT_LOWER_BOUND_SCAN_U32(arr, target, from, to)

#define VECT_SET_BLOCK_BITS(block, idx, start, stop)

#define VECT_BITCOUNT_SUB(first, last, mask)

#define VECT_BITCOUNT_XOR(first, last, mask)

#define VECT_AND_DIGEST(dst, src)

#define VECT_GAP_BFIND(buf, pos, is_set)

#define VECT_INVERT_BLOCK(first)

#define VECT_BLOCK_CHANGE(block, size)

#define VECT_SUB_DIGEST_3WAY(dst, src1, src2)

#define VECT_AND_DIGEST_2WAY(dst, src1, src2)

#define VECT_AND_OR_DIGEST_2WAY(dst, src1, src2)

#define VECT_BLOCK_SET_DIGEST(dst, val)

#define VECT_AND_DIGEST_3WAY(dst, src1, src2)

#define BM_AVX2_BIT_COUNT(ret, v)

#define VECT_ARR_BLOCK_LOOKUP(idx, size, nb, start)

#define VECT_BITCOUNT(first, last)

#define VECT_SUB_DIGEST(dst, src)

#define VECT_OR_BLOCK_3WAY(dst, src1, src2)

#define VECT_OR_BLOCK_2WAY(dst, src1, src2)

#define VECT_AND_BLOCK(dst, src)

#define IS_FULL_BLOCK(addr)

#define IS_VALID_ADDR(addr)

#define FULL_BLOCK_FAKE_ADDR

#define IS_EMPTY_BLOCK(addr)

#define BM_VECT_ALIGN_ATTR

#define FULL_BLOCK_REAL_ADDR

Bit manipulation primitives (internal)

Bit-block get adapter, takes bitblock and represents it as a get_32() accessor function.

bitblock_get_adapter(const bm::word_t *bit_block)

bm::word_t get_32() noexcept

Bit-block store adapter, takes bitblock and saves results into it.

bitblock_store_adapter(bm::word_t *bit_block)

void push_back(bm::word_t w)

Bit-block sum adapter, takes values and sums it /internal.

bm::word_t sum() const noexcept

Get accumulated sum.

void push_back(bm::word_t w) noexcept

Adaptor to copy 1 bits to array.

copy_to_array_functor(B *bits)

copy_to_array_functor(const copy_to_array_functor &)

void operator()(unsigned bit_idx0, unsigned bit_idx1) noexcept

void operator()(unsigned bit_idx0, unsigned bit_idx1, unsigned bit_idx2, unsigned bit_idx3) noexcept

void operator()(unsigned bit_idx) noexcept

void operator()(unsigned bit_idx0, unsigned bit_idx1, unsigned bit_idx2) noexcept

copy_to_array_functor & operator=(const copy_to_array_functor &)

Adapter to get words from a range stream (see range serialized bit-block)

bm::word_t get_32() noexcept

decoder_range_adapter(DEC &dec, unsigned from_idx, unsigned to_idx)

static vector< string > arr

static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)

static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)

static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)

bool avx2_test_all_zero_wave(const void *ptr)

check if wave of pointers is all NULL

bool sse42_test_all_zero_wave(const void *ptr) noexcept

check if wave of pointers is all NULL

NCBI_NS_STD::string::size_type SIZE_TYPE

bm::id_t bit_block_count(const bm::word_t *block) noexcept

Bitcount for bit block.

unsigned bit_find_last(const bm::word_t *block, unsigned *last) noexcept

BIT block find the last set bit (backward search)

unsigned short bitscan_bsf64(bm::id64_t w, B *bits) noexcept

Unpacks word into list of ON bits (BSF/__builtin_ctz)

bool bit_find_first(const bm::word_t *block, unsigned *pos) noexcept

BIT block find the first set bit.

void bit_block_copy_unalign(bm::word_t *dst, const bm::word_t *src) noexcept

Bitblock copy operation (unaligned src)

unsigned word_select32(unsigned w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

bm::id64_t bit_block_and_3way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept

digest based bit-block AND

void or_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept

Sets bits to 1 in the bitblock.

bool bit_block_shift_r1(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept

Right bit-shift bitblock by 1 bit (reference)

void bit_block_gather_scatter(TRGW *arr, const bm::word_t *blk, const IDX *idx, SZ size, SZ start, unsigned bit_idx) noexcept

bit index to word gather-scatter algorithm

int wordcmp0(T w1, T w2) noexcept

Lexicographical comparison of two words as bit strings (reference) Auxiliary implementation for testi...

void block_compact_by_digest(bm::word_t *t_block, const bm::word_t *block, bm::id64_t digest, bool zero_tail) noexcept

Compact sub-blocks by digest (rank compaction)

bm::id64_t digest_mask(unsigned from, unsigned to) noexcept

Compute digest mask for [from..to] positions.

unsigned bit_count_nonzero_size(const T *blk, unsigned data_size) noexcept

Inspects block for full zero words.

void xor_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept

XOR bit interval to 1 in the bitblock.

bm::word_t * bit_operation_sub(bm::word_t *dst, const bm::word_t *src) noexcept

bitblock SUB operation.

unsigned word_bitcount64(bm::id64_t x) noexcept

bm::id_t bit_operation_sub_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock SUB operation and calculates bitcount of the result.

bm::id64_t bit_block_xor(bm::word_t *dst, const bm::word_t *src) noexcept

Plain bitblock XOR operation. Function does not analyse availability of source and destination blocks...

unsigned word_select64_bitscan_tz(bm::id64_t w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

bool bit_block_shift_r1_and(bm::word_t *block, bm::word_t co_flag, const bm::word_t *mask_block, bm::id64_t *digest) noexcept

Right bit-shift of bit-block by 1 bit (reference) + AND.

bool bit_find_first_diff(const bm::word_t *blk1, const bm::word_t *blk2, unsigned *pos) noexcept

Find first bit which is different between two bit-blocks.

bool bit_block_find_interval_start(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept

Searches for the first 1 bit in the 111 interval of a BIT block.

unsigned bit_block_and_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function ANDs two bitblocks and tests for any bit. Function does not analyse availability of source b...

unsigned short bitscan_popcnt64(bm::id64_t w, B *bits) noexcept

Unpacks 64-bit word into list of ON bit indexes using popcnt method.

bm::id_t word_bitcount(bm::id_t w) noexcept

void bit_invert(T *start) noexcept

bool bit_block_or(bm::word_t *dst, const bm::word_t *src) noexcept

Plain bitblock OR operation. Function does not analyse availability of source and destination blocks.

unsigned short bitscan_bsf(unsigned w, B *bits) noexcept

Unpacks word into list of ON bits (BSF/__builtin_ctz)

bm::id64_t bit_block_and(bm::word_t *dst, const bm::word_t *src) noexcept

Plain bitblock AND operation. Function does not analyse availability of source and destination blocks...

void bit_block_stream_unalign(bm::word_t *dst, const bm::word_t *src) noexcept

Bitblock copy/stream operation (unaligned src)

unsigned bit_block_convert_to_arr(T *dest, const unsigned *src, bool inverted) noexcept

Convert bit block into an array of ints corresponding to 1 bits.

bool bit_block_shift_l1(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept

Left bit-shift bitblock by 1 bit (reference)

bm::id64_t update_block_digest0(const bm::word_t *const block, bm::id64_t digest) noexcept

Compute digest for 64 non-zero areas based on existing digest (function revalidates zero areas)

void bit_andnot_arr_ffmask(bm::word_t *dst, const bm::word_t *src) noexcept

bitblock AND NOT with constant ~0 mask operation.

bool bit_block_shift_l1_unr_min(bm::word_t *block, bm::word_t *empty_acc, unsigned co_flag) noexcept

Left bit-shift bitblock by 1 bit (minimum unroll)

void bit_block_stream(bm::word_t *dst, const bm::word_t *src) noexcept

Bitblock copy/stream operation.

void bit_block_rle_split(T *dst_s, T *dst_r, T *rlen, unsigned &s_cnt, unsigned &r_cnt, const unsigned *src, bool inverted) noexcept

Convert bit block into two arrays of ints( corresponding to 1 bits)

void block_init_digest0(bm::word_t *const block, bm::id64_t digest) noexcept

Init block with 000111000 pattren based on digest.

bool bit_block_or_3way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept

3 way (target | source1 | source2) bitblock OR operation. Function does not analyse availability of s...

bool bit_block_find_interval_end(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept

Searches for the last 1 bit in the 111 interval of a BIT block.

bool bit_block_or_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept

2 way (target := source1 | source2) bitblock OR operation.

unsigned bit_block_find(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept

Searches for the next 1 bit in the BIT block.

bool is_bits_one(const bm::wordop_t *start) noexcept

Returns "true" if all bits in the block are 1.

bm::id_t bit_block_calc_count_range(const bm::word_t *block, bm::word_t left, bm::word_t right) noexcept

bool bit_block_shift_r1_unr_min(bm::word_t *block, bm::word_t *empty_acc, bm::id64_t co_flag) noexcept

Right bit-shift bitblock by 1 bit (minimum unroll)

unsigned short bitscan(V w, B *bits) noexcept

Templated Bitscan with dynamic dispatch for best type.

unsigned short bitscan_wave(const bm::word_t *w_ptr, unsigned char *bits) noexcept

Unpacks word wave (Nx 32-bit words)

bm::id_t bit_operation_xor_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock XOR operation test.

SIZE_TYPE bit_find_rank(const bm::word_t *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept

BIT block find position for the rank.

bm::id_t bit_count_change(bm::word_t w) noexcept

unsigned bitcount64_4way(bm::id64_t x, bm::id64_t y, bm::id64_t u, bm::id64_t v) noexcept

bm::id64_t bit_block_and_or_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept

digest based bit-block AND - OR

bool bit_is_all_zero(const bm::word_t *start) noexcept

Returns "true" if all bits in the block are 0.

bool bit_block_shift_r1_unr(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept

Right bit-shift of bit-block by 1 bit (loop unrolled)

void bit_for_each_4(T w, F &func)

Templated algorithm to unpacks octet based word into list of ON bit indexes.

unsigned bit_block_sub_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function SUBs two bitblocks and computes the bitcount. Function does not analyse availability of sour...

unsigned word_select64(bm::id64_t w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

unsigned bit_block_xor_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function XORs two bitblocks and and tests for any bit. Function does not analyse availability of sour...

void bit_block_set(bm::word_t *dst, bm::word_t value) noexcept

Bitblock memset operation.

unsigned test_bit(const unsigned *block, unsigned bitpos) noexcept

Test 1 bit in a block.

void bit_block_rotate_left_1_unr(bm::word_t *block) noexcept

Unrolled cyclic rotation of bit-block left by 1 bit.

bm::id_t bit_operation_or_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock OR operation test.

unsigned bit_list_4(T w, B *bits) noexcept

Unpacks word into list of ON bit indexes (quad-bit based)

bool bit_block_or_5way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, const bm::word_t *src4) noexcept

5 way (target, source1, source2) bitblock OR operation. Function does not analyse availability of sou...

bm::id_t bit_block_calc_count_to(const bm::word_t *block, bm::word_t right) noexcept

void bit_for_each(T w, F &func)

Templated algorithm to unpacks word into list of ON bit indexes.

void bit_block_copy(bm::word_t *dst, const bm::word_t *src) noexcept

Bitblock copy operation.

unsigned bit_block_sub_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function SUBs two bitblocks and and tests for any bit. Function does not analyse availability of sour...

unsigned bit_scan_reverse(T value) noexcept

bm::id_t bit_block_any_range(const bm::word_t *block, bm::word_t left, bm::word_t right) noexcept

bm::id64_t bit_block_and_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept

digest based bit-block AND

bool bit_block_shift_l1_unr(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept

Left bit-shift of bit-block by 1 bit (loop unrolled)

bm::set_representation best_representation(unsigned bit_count, unsigned total_possible_bitcount, unsigned gap_count, unsigned block_size) noexcept

Choose best representation for a bit-block.

unsigned word_select64_linear(bm::id64_t w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

unsigned word_select32_bitscan_tz(unsigned w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

bm::id_t bit_operation_and_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock AND operation test.

bool bit_block_shift_r1_and_unr(bm::word_t *block, bm::word_t co_flag, const bm::word_t *mask_block, bm::id64_t *digest) noexcept

Right bit-shift bitblock by 1 bit (reference) + AND.

bm::id64_t bit_block_sub_3way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, bm::id64_t digest) noexcept

digest based bit-block SUB 3-way

unsigned word_select32_bitscan_popcnt(unsigned w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

void sub_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept

SUB (AND NOT) bit interval to 1 in the bitblock.

unsigned word_select64_bitscan_popcnt(bm::id64_t w, unsigned rank) noexcept

word find index of the rank-th bit set by bit-testing

bm::word_t bit_block_insert(bm::word_t *block, unsigned bitpos, bool value) noexcept

insert bit into position and shift the rest right with carryover

bm::word_t * bit_operation_xor(bm::word_t *dst, const bm::word_t *src) noexcept

bitblock XOR operation.

void clear_bit(unsigned *dest, unsigned bitpos) noexcept

Set 1 bit in a block.

void bit_block_erase(bm::word_t *block, unsigned bitpos, bool carry_over) noexcept

erase bit from position and shift the rest right with carryover

void set_bit(unsigned *dest, unsigned bitpos) noexcept

Set 1 bit in a block.

bm::id64_t widx_to_digest_mask(unsigned w_idx) noexcept

Compute digest mask for word address in block.

bm::word_t * bit_operation_and(bm::word_t *dst, const bm::word_t *src) noexcept

bitblock AND operation.

unsigned bit_block_or_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function ORs two bitblocks and and tests for any bit. Function does not analyse availability of sourc...

bm::id_t bit_operation_xor_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock XOR operation and calculates bitcount of the result.

unsigned bit_list(T w, B *bits) noexcept

Unpacks word into list of ON bit indexes.

void bit_block_rle_set(unsigned *blk, const T *s, const T *r, const T *rlen, unsigned s_cnt, unsigned r_cnt) noexcept

Set bits using rle split scheme (reverse of bit_block_rle_split)

int bitcmp(const T *buf1, const T *buf2, unsigned len) noexcept

Lexicographical comparison of BIT buffers.

bm::id_t bit_operation_sub_count_inv(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs inverted bitblock SUB operation and calculates bitcount of the result.

unsigned bit_block_and_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function ANDs two bitblocks and computes the bitcount. Function does not analyse availability of sour...

bool bit_find_first_if_1(const bm::word_t *block, unsigned *first, bm::id64_t digest) noexcept

BIT block find the first set bit if only 1 bit is set.

int wordcmp(T a, T b) noexcept

Lexicographical comparison of two words as bit strings. Auxiliary implementation for testing and refe...

bm::id_t bit_operation_sub_any(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock test of SUB operation.

bm::id64_t bit_block_sub_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept

digest based bitblock SUB (AND NOT) operation (3 operand)

bm::id64_t bit_block_sub_5way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, bm::id64_t digest) noexcept

digest based bit-block SUB 5-way

bm::word_t * bit_operation_or(bm::word_t *dst, const bm::word_t *src) noexcept

Block OR operation. Makes analysis if block is 0 or FULL.

void block_expand_by_digest(bm::word_t *t_block, const bm::word_t *block, bm::id64_t digest, bool zero_subs) noexcept

expand sub-blocks by digest (rank expansion)

bm::id64_t bit_block_init_and_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept

digest based bit-block AND (0 elements of digest will be zeroed)

bool bit_block_find_prev(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept

Reverse search for the previous 1 bit.

unsigned bit_block_xor_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function XORs two bitblocks and computes the bitcount. Function does not analyse availability of sour...

bool bit_block_is_all_one_range(const bm::word_t *const block, bm::word_t left, bm::word_t right) noexcept

bm::id_t bit_operation_or_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock OR operation and calculates bitcount of the result.

unsigned bit_block_calc_change(const bm::word_t *block) noexcept

bm::id64_t calc_block_digest0(const bm::word_t *const block) noexcept

Compute digest for 64 non-zero areas.

void bit_block_rotate_left_1(bm::word_t *block) noexcept

unsigned bit_count_min_unroll(const bm::word_t *block, const bm::word_t *block_end) noexcept

Bitcount for bit block without agressive unrolling.

unsigned bit_block_or_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Function ORs two bitblocks and computes the bitcount. Function does not analyse availability of sourc...

bool check_zero_digest(bm::id64_t digest, unsigned bitpos_from, unsigned bitpos_to) noexcept

check if all digest bits for the range [from..to] are 0

bm::id64_t bit_block_and_5way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, bm::id64_t digest) noexcept

digest based bit-block AND 5-way

bm::id64_t bit_block_xor_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept

2 way (target := source1 ^ source2) bitblock XOR operation.

bm::id_t bit_operation_and_count(const bm::word_t *src1, const bm::word_t *src2) noexcept

Performs bitblock AND operation and calculates bitcount of the result.

bm::id64_t bit_block_sub(bm::word_t *dst, const bm::word_t *src) noexcept

Plain bitblock SUB (AND NOT) operation. Function does not analyse availability of source and destinat...

unsigned short bitscan_popcnt(bm::id_t w, B *bits, unsigned short offs) noexcept

Unpacks word into list of ON bit indexes using popcnt method.

operation

Bit operations.

set_operation

Codes of set operations.

bm::id_t gap_bitset_sub_any(const unsigned *block, const T *buf) noexcept

Compute bitcount test of bit block SUB masked by GAP block.

unsigned gap_operation_any_xor(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP XOR operation test.

bool gap_any_range(const T *const buf, unsigned left, unsigned right) noexcept

Test if any bits are 1 in GAP buffer in the [left, right] range.

unsigned gap_bit_count_range(const T *const buf, unsigned left, unsigned right) noexcept

Counts 1 bits in GAP buffer in the closed [left, right] range.

unsigned gap_limit(const T *buf, const T *glevel_len) noexcept

Returs GAP block capacity limit.

unsigned gap_overhead(const T *length, const T *length_end, const T *glevel_len) noexcept

Calculates memory overhead for number of gap blocks sharing the same memory allocation table (level l...

bool gap_is_all_one(const bm::gap_word_t *buf) noexcept

Checks if GAP block is all-one.

gap_word_t * gap_operation_xor(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept

GAP XOR operation.

unsigned gap_count_or(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP bitcount OR operation test.

unsigned gap_free_elements(const T *buf, const T *glevel_len) noexcept

Returns number of free elements in GAP block array. Difference between GAP block capacity on this lev...

bool gap_shift_r1(T *buf, unsigned co_flag, unsigned *new_len) noexcept

Right shift GAP block by 1 bit.

bool gap_find_first_diff(const T *buf1, const T *buf2, unsigned *pos) noexcept

Find first bit which is different between two GAP-blocks.

void gap_invert(T *buf) noexcept

Inverts all bits in the GAP buffer.

bm::id_t gap_bitset_xor_count(const unsigned *block, const T *buf) noexcept

Compute bitcount of bit block XOR masked by GAP block.

void gap_add_to_bitset(unsigned *dest, const T *pcurr, unsigned len) noexcept

Adds(OR) GAP block to bitblock.

void set_gap_level(T *buf, int level) noexcept

Sets GAP block capacity level.

void gap_init_range_block(T *buf, T from, T to, T value) noexcept

Init gap block so it has block in it (can be whole block)

unsigned gap_set_array(T *buf, const T *arr, unsigned len) noexcept

Convert array to GAP buffer.

gap_word_t * gap_operation_or(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept

GAP OR operation.

unsigned gap_test(const T *buf, unsigned pos) noexcept

Tests if bit = pos is true.

bm::id_t gap_bitset_sub_count(const unsigned *block, const T *buf) noexcept

Compute bitcount of bit block SUB masked by GAP block.

void gap_validate(const T *buf, unsigned dsize=0) noexcept

Validates GAP block.

unsigned gap_count_xor(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP bitcount XOR operation test.

bool improve_gap_levels(const T *length, const T *length_end, T *glevel_len) noexcept

Finds optimal gap blocks lengths.

unsigned gap_bit_count(const T *buf, unsigned dsize=0) noexcept

Calculates number of bits ON in GAP buffer.

unsigned gap_control_sum(const T *buf) noexcept

Calculates sum of all words in GAP block. (For debugging purposes)

unsigned gap_test_unr(const T *buf, const unsigned pos) noexcept

Tests if bit = pos is true. Analog of bm::gap_test with SIMD unrolling.

bool gap_is_all_zero(const bm::gap_word_t *buf) noexcept

Checks if GAP block is all-zero.

void gap_convert_to_bitset(unsigned *dest, const T *buf, unsigned len=0) noexcept

GAP block to bitblock conversion.

gap_word_t * gap_operation_sub(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept

GAP SUB (AND NOT) operation.

unsigned gap_buff_any_op(const T *vect1, unsigned vect1_mask, const T *vect2, unsigned vect2_mask)

Abstract distance test operation for GAP buffers. Receives functor F as a template argument.

void for_each_gap_dbit(const T *buf, F &func)

Iterate gap block as delta-bits with a functor.

unsigned gap_count_sub(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP bitcount SUB (AND NOT) operation test.

void gap_xor_to_bitset(unsigned *dest, const T *pcurr) noexcept

XOR GAP block to bitblock.

bool gap_find_prev(const T *const buf, unsigned nbit, unsigned *pos) noexcept

reverse search for the first 1 bit of a GAP block

unsigned gap_set_value_cpos(unsigned val, T *buf, unsigned pos, unsigned *is_set, unsigned curr) noexcept

Sets or clears bit in the GAP buffer.

gap_word_t * gap_operation_and(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept

GAP AND operation.

bm::id_t gap_bitset_xor_any(const unsigned *block, const T *buf) noexcept

Compute bitcount test of bit block XOR masked by GAP block.

SIZE_TYPE gap_find_rank(const T *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept

GAP block find position for the rank.

unsigned gap_bit_count_unr(const T *buf) noexcept

Calculates number of bits ON in GAP buffer. Loop unrolled version.

unsigned arr_calc_delta_min_w(const T *arr, unsigned arr_len, unsigned wlen, unsigned min0, unsigned *wflags) noexcept

calculate minimal delta between monotonic growing numbers with windows

unsigned gap_operation_any_and(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP AND operation test.

unsigned gap_set_value(unsigned val, T *buf, unsigned pos) noexcept

Sets or clears bit in the GAP buffer.

bm::id_t gap_bitset_or_count(const unsigned *block, const T *buf) noexcept

Compute bitcount of bit block OR masked by GAP block.

unsigned gap_find_first(const T *buf, unsigned *first) noexcept

GAP block find the first set bit.

bm::id_t gap_bitset_and_count(const unsigned *block, const T *pcurr) noexcept

Compute bitcount of bit block AND masked by GAP block.

unsigned gap_find_last(const T *buf, unsigned *last) noexcept

GAP block find the last set bit.

bool gap_split(const T *buf, unsigned len, unsigned h_limit, const unsigned *hist0, const unsigned *hist1, T *tbuf, T *ex0_arr, T *ex1_arr, unsigned &ex0_cnt, unsigned &ex1_cnt) noexcept

split GAP block into pure GAPs and exceptions

unsigned gap_capacity(const T *buf, const T *glevel_len) noexcept

Returs GAP block capacity.

T gap_level(const T *buf) noexcept

Returs GAP blocks capacity level.

unsigned gap_block_find(const T *buf, unsigned nbit, bm::id_t *prev) noexcept

Searches for the next 1 bit in the GAP block.

int gap_calc_level(unsigned len, const T *glevel_len) noexcept

Calculates GAP block capacity level.

unsigned gap_count_and(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP bitcount AND operation test.

unsigned bit_block_to_gap(gap_word_t *dest, const unsigned *block, unsigned dest_len) noexcept

Converts bit block to GAP.

bool gap_is_all_one_range(const T *const buf, unsigned left, unsigned right) noexcept

Test if all bits are 1 in GAP buffer in the [left, right] range.

bool arr_calc_delta_min(const T *arr, unsigned arr_len, T &min0) noexcept

calculate minimal delta between monotonic growing numbers

bm::id_t gap_bitset_and_any(const unsigned *block, const T *pcurr) noexcept

Bitcount test of bit block AND masked by GAP block.

bool gap_find_interval_end(const T *const buf, unsigned nbit, unsigned *pos) noexcept

Searches for the last 1 bit in the 111 interval of a GAP block.

unsigned gap_operation_any_sub(const gap_word_t *vect1, const gap_word_t *vect2) noexcept

GAP SUB operation test.

bm::id_t gap_bitset_or_any(const unsigned *block, const T *buf) noexcept

Compute bitcount test of bit block OR masked by GAP block.

bool gap_shift_l1(T *buf, unsigned co_flag, unsigned *new_len) noexcept

Left shift GAP block by 1 bit.

void gap_calc_mins(const T *buf, T &min0, T &min1) noexcept

minimal delta sizes

void gap_calc_hist(const T *buf, unsigned len, unsigned *hist0, unsigned *hist1, unsigned hist_len) noexcept

compute histogram of exceptions on GAP block

void gap_and_to_bitset(unsigned *dest, const T *pcurr) noexcept

ANDs GAP block to bitblock.

void gap_restore_mins(T *buf, T min0, T min1) noexcept

Restore GAP block using two minimal GAP lens.

bool gap_find_interval_start(const T *const buf, unsigned nbit, unsigned *pos) noexcept

Searches for the first 1 bit in the 111 interval of a GAP block.

int gapcmp(const T *buf1, const T *buf2) noexcept

Lexicographical comparison of GAP buffers.

T gap_recalc_mins(T *tbuf, const T *buf, T min0, T min1) noexcept

Recalculate GAP block using two minimal GAP lens.

unsigned gap_bit_count_range_hint(const T *const buf, unsigned left, unsigned right, unsigned hint) noexcept

Counts 1 bits in GAP buffer in the closed [left, right] range using position hint to avoid bfind.

bm::gap_word_t gap_length(const bm::gap_word_t *buf) noexcept

Returs GAP block length.

void gap_set_all(T *buf, unsigned set_max, unsigned value) noexcept

Sets all bits to 0 or 1 (GAP)

void gap_sub_to_bitset(unsigned *dest, const T *pcurr) noexcept

SUB (AND NOT) GAP block to bitblock.

bool gap_is_interval(const T *const buf, unsigned left, unsigned right) noexcept

Test if any bits are 1 in GAP buffer in the [left, right] range and flanked with 0s.

unsigned * gap_convert_to_bitset_smart(unsigned *dest, const T *buf, id_t set_max) noexcept

Smart GAP block to bitblock conversion.

unsigned bit_array_compute_gaps(const T *arr, unsigned len) noexcept

Compute number of GAPs in bit-array.

unsigned gap_buff_count_op(const T *vect1, const T *vect2)

Abstract distance(similarity) operation for GAP buffers. Receives functor F as a template argument.

D gap_convert_to_arr(D *dest, const T *buf, unsigned dest_len, bool invert=false) noexcept

Convert gap block into array of ints corresponding to 1 bits.

unsigned gap_add_value(T *buf, unsigned pos) noexcept

Add new value to the end of GAP buffer.

void arr_delta1_split(T *arr_d1, unsigned &d1_len, T *arr_dst, unsigned &dst_len, const T *arr, unsigned arr_len, unsigned ex_max_delta) noexcept

split array based on delta exceptions

bool gap_insert(T *buf, unsigned pos, unsigned val, unsigned *new_len) noexcept

isnert bit into GAP compressed block

unsigned int

A callback function used to compare two keys in a database.

const unsigned set_array_mask

bool block_ptr_array_range(bm::word_t **arr, unsigned &left, unsigned &right) noexcept

array range detector

const unsigned set_block_digest_wave_size

void for_each_nzblock(T ***root, unsigned size1, F &f)

SIZE_TYPE block_find_rank(const bm::word_t *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept

Find rank in block (GAP or BIT)

bm::id_t(* bit_operation_count_func_type)(const bm::word_t *, const bm::word_t *)

void arr_restore_min_w(T *arr, unsigned arr_len, unsigned wlen, T min0, const unsigned *wflags) noexcept

Restore array using two minimal delta for better BIC compression.

SZ count_nz(const VT *arr, SZ arr_size) noexcept

Find count of non-zero elements in the array.

void bit_recomb(It1 &it1, It2 &it2, BinaryOp &op, Encoder &enc, unsigned block_size=bm::set_block_size) noexcept

bool block_find_reverse(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept

Reverse find 1.

const unsigned set_block_mask

const bm::gap_word_t * avx2_gap_sum_arr(const bm::gap_word_t *pbuf, unsigned avx_vect_waves, unsigned *sum)

bm::id64_t dm_control(unsigned from, unsigned to) noexcept

digest mask control generation (for debug and test only)

bool find_not_null_ptr(const bm::word_t *const *const *arr, N start, N size, N *pos) noexcept

unsigned lower_bound_linear_u64(const unsigned long long *arr, unsigned long long target, unsigned from, unsigned to) noexcept

Linear lower bound search in unsigned LONG array.

unsigned gap_bit_count_to(const T *const buf, T right) noexcept

void gap_buff_op(T *dest, const T *vect1, unsigned vect1_mask, const T *vect2, unsigned vect2_mask, unsigned &dlen)

Abstract operation for GAP buffers. Receives functor F as a template argument.

bool block_any(const bm::word_t *const block) noexcept

Returns "true" if one bit is set in the block Function check for block varieties.

T arr_recalc_min(T *tarr, const T *arr, unsigned arr_len, T min0, T delta_acc=0) noexcept

Recalculate array using minimal delta for better BIC compression.

const unsigned set_sub_array_size

bm::id64_t sum_arr(const T *first, const T *last) noexcept

void get_block_coord(BI_TYPE nb, unsigned &i, unsigned &j) noexcept

Recalc linear bvector block index into 2D matrix coordinates.

unsigned bit_block_change64(const bm::word_t *in_block, unsigned size) noexcept

bool check_block_zero(const bm::word_t *blk, bool deep_scan) noexcept

Checks all conditions and returns true if block consists of only 0 bits.

bm::id_t block_to_global_index(unsigned i, unsigned j, unsigned block_idx) noexcept

calculate bvector<> global bit-index from block-local coords

void for_each_dgap(const T *gap_buf, Func &func)

bool find_first_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept

Find max non-zero value in an array.

bm::id64_t idx_arr_block_lookup_u64(const bm::id64_t *idx, bm::id64_t size, bm::id64_t nb, bm::id64_t start) noexcept

block boundaries look ahead U32

bool is_const_set_operation(bm::set_operation op) noexcept

Returns true if set operation is constant (bitcount)

unsigned count_trailing_zeros_u64(bm::id64_t w) noexcept

64-bit bit-scan fwd

void for_each_nzblock_range(T ***root, N top_size, N nb_from, N nb_to, F &f) noexcept

RTYPE get_super_block_start(unsigned i) noexcept

Compute bit address of the first bit in a superblock.

unsigned bit_block_change32(const bm::word_t *block, unsigned size) noexcept

set_representation

set representation variants

@ set_gap

GAP-RLE compression.

@ set_bitset

Simple bitset.

@ set_array1

array of set 1 values

@ set_array0

array of 0 values

bool block_is_all_one_range(const bm::word_t *const block, unsigned left, unsigned right) noexcept

Returns "true" if all bits are 1 in the block [left, right] Function check for block varieties.

void simple_swap(T *a, T *b) noexcept

swap function for simple types

unsigned long long bmi_bslr_u64(unsigned long long w) noexcept

void bit_block_ex0_split(unsigned *block, T *arr_ex0, unsigned &ex0_cnt, bool inverted) noexcept

Extract standalone 0s out of bit-block.

unsigned block_find_interval_start(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept

Find start of the current 111 interval.

bool check_block_one(const bm::word_t *blk, bool deep_scan) noexcept

Checks if block has only 1 bits.

bool bit_block_ex0_split_check(const unsigned *, const unsigned *tb, const T *ex0_arr, unsigned ex0_cnt) noexcept

validate split results (for DEBUGGING)

bm::id64_t ptrp_test(ptr_payload_t ptr, bm::gap_word_t v) noexcept

bool find_max_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept

Find max non-zero value in an array.

bool find_ptr(const void *const *p_arr, size_t arr_size, const void *ptr, size_t *idx) noexcept

Scan search for pointer value in unordered array.

void bit_block_change_bc(const bm::word_t *block, unsigned *gc, unsigned *bc) noexcept

unsigned idx_arr_block_lookup_u32(const unsigned *idx, unsigned size, unsigned nb, unsigned start) noexcept

block boundaries look ahead U32

const unsigned gap_levels

gap_word_t *(* gap_operation_func_type)(const gap_word_t *, const gap_word_t *, gap_word_t *, unsigned &)

void for_each_nzblock2(T ***root, unsigned size1, F &f)

F bmfor_each(T first, T last, F f)

bool compute_wdr_params(const T *arr, unsigned sz, bm::word_t *tb_wflags, unsigned min0, unsigned &win_size, float &best_save)

unsigned bitscan_nibble(unsigned w, unsigned *bits) noexcept

portable, switch based bitscan

void set_nibble(unsigned char *arr, unsigned idx, unsigned char v) noexcept

set nibble in the array

const unsigned set_word_shift

unsigned char get_nibble(const unsigned char *arr, unsigned idx) noexcept

get nibble from the array

unsigned arr_cnt_zero_splits(T *arr, unsigned sz) noexcept

const unsigned set_sub_total_bits

const unsigned set_block_digest_pos_shift

bool for_each_nzblock_if(T ***root, BI size1, F &f) noexcept

const unsigned set_block_size

unsigned bit_to_gap(gap_word_t *dest, const unsigned *block, unsigned dest_len) noexcept

Convert bit block to GAP representation.

unsigned long long int id64_t

const unsigned block_waves

bool block_is_interval(const bm::word_t *const block, unsigned left, unsigned right) noexcept

Returns "true" if all bits are 1 in the block [left, right] and border bits are 0.

unsigned gap_bfind(const T *buf, unsigned pos, unsigned *is_set) noexcept

void arr_restore_min(T *arr, unsigned arr_len, T min0, T delta_acc=0) noexcept

Restore array using two minimal delta for better BIC compression.

bool block_find_first_diff(const bm::word_t *blk, const bm::word_t *arg_blk, unsigned *pos) noexcept

Find first bit which is different between two blocks (GAP or bit)

const unsigned gap_max_buff_len

unsigned mask_r_u32(unsigned nbit) noexcept

bm::operation setop2op(bm::set_operation op) noexcept

Convert set operation to operation.

bit_representation

Possible representations for bit sets.

@ e_bit_bit

uncompressed bit-block

@ e_bit_0

all 0s (empty block)

@ e_bit_IINT

Inverted int list.

unsigned bit_scan_forward32(unsigned w) noexcept

bool is_digest_one_range(bm::id64_t digest) noexcept

Is one range of 1s ( 0000110000 - one range, 000011000010 - more than one)

unsigned lower_bound_u32(const unsigned *arr, unsigned target, unsigned from, unsigned to) noexcept

Hybrid, binary-linear lower bound search in unsigned array.

int parallel_popcnt_32(unsigned int n) noexcept

32-bit paralle, bitcount

void dgap_2_gap(const T *dgap_buf, T *gap_buf, T gap_header=0) noexcept

Convert D-GAP buffer into GAP buffer.

void sse4_bit_block_gather_scatter(unsigned *arr, const unsigned *blk, const unsigned *idx, unsigned size, unsigned start, unsigned bit_idx) noexcept

unsigned lower_bound_linear_u32(const unsigned *arr, unsigned target, unsigned from, unsigned to) noexcept

Linear lower bound search in unsigned array.

const unsigned short set_bitscan_wave_size

Size of bit decode wave in words.

const unsigned set_array_shift

unsigned min_delta_u32(const unsigned *arr, size_t arr_size)

Calculate minimal delta between elements of sorted array.

unsigned short gap_word_t

bool debug_check_count_range(const T *const buf, const unsigned left, const unsigned start_pos, const unsigned is_set) noexcept

Debug function for verification in DEBUG mode.

void(* gap_operation_to_bitset_func_type)(unsigned *, const gap_word_t *)

T arr_recalc_min_w(T *tarr, const T *arr, unsigned arr_len, unsigned wlen, T min0, const unsigned *wflags) noexcept

Recalculate array using two minimal delta for better BIC compression.

unsigned block_find_interval_end(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept

Find end of the current 111 interval.

void avx2_bit_block_gather_scatter(unsigned *arr, const unsigned *blk, const unsigned *idx, unsigned size, unsigned start, unsigned bit_idx)

const unsigned gap_max_bits

void set_block_bits_u64(bm::word_t *block, const bm::id64_t *idx, bm::id64_t start, bm::id64_t stop) noexcept

set bits in a bit-block using global index

void for_each_block(T ***root, unsigned size1, F &f, BLOCK_IDX start)

const word_t all_bits_mask

const unsigned set_block_shift

void set_block_bits_u32(bm::word_t *block, const unsigned *idx, unsigned start, unsigned stop) noexcept

set bits in a bit-block using global index

T * gap_2_dgap(const T *gap_buf, T *dgap_buf, bool copy_head=true) noexcept

Convert GAP buffer into D-GAP buffer.

const unsigned set_word_mask

unsigned count_leading_zeros_u64(bm::id64_t w) noexcept

64-bit bit-scan reverse

unsigned count_trailing_zeros_u32(unsigned w) noexcept

32-bit bit-scan fwd

void quick_sort2(T *arr, int first, int last) noexcept

simple recursive quick-sort for short integer arrays

unsigned calc_hist_limit(const unsigned *hist0, const unsigned *hist1, unsigned hist_len, unsigned ex_limit, unsigned *ex_sum) noexcept

claculate the effective exceptions limit using two histograms

void min_delta_apply(unsigned *arr, size_t arr_size, unsigned delta) noexcept

Recalculate the array to decrement delta as arr[i] = arr[i] - delta + 1 so that array remains monoton...

const unsigned bits_in_block

bool block_any_range(const bm::word_t *const block, unsigned left, unsigned right) noexcept

Returns "true" if one bit is set in the block [left, right] Function check for block varieties.

const bm::gap_word_t * sse2_gap_sum_arr(const bm::gap_word_t *BMRESTRICT pbuf, unsigned sse_vect_waves, unsigned *sum) BMNOEXCEPT

Gap block population count (array sum) utility.

unsigned long long bmi_blsi_u64(unsigned long long w)

unsigned bit_scan_reverse32(unsigned w) noexcept

RTYPE get_block_start(unsigned i, unsigned j) noexcept

Compute bit address of the first bit in a block.

unsigned mask_l_u32(unsigned nbit) noexcept

unsigned lower_bound_u64(const unsigned long long *arr, unsigned long long target, unsigned from, unsigned to) noexcept

Hybrid, binary-linear lower bound search in unsigned LONG array.

const struct ncbi::grid::netcache::search::fields::SIZE size

const GenericPointer< typename T::ValueType > T2 value

#define F(x)

Make a parametrized function appear to have only one variable.

Int4 delta(size_t dimension_, const Int4 *score_)

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

static int _mm_test_all_zeros(__m128i a, __m128i mask)

static __m128i _mm_loadu_si128(const __m128i *p)

static __m128i _mm_load_si128(const __m128i *p)

static int _mm_testz_si128(__m128i a, __m128i b)

static int64_t _mm_popcnt_u64(uint64_t a)

bm::word_t _p[bm::set_block_size]

Structure carries pointer on bit block with all bits 1.

static bool is_valid_block_addr(const bm::word_t *bp) noexcept

static bool is_full_block(const bm::word_t *bp) noexcept

static bm::id64_t block_type(const bm::word_t *bp) noexcept

static all_set_block _block

W operator()(W w1, W w2) noexcept

W operator()(W, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W) noexcept

W operator()(W, W w2) noexcept

W operator()(W w1, W w2) noexcept

Bit COUNT SUB AB functor.

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

W operator()(W w1, W w2) noexcept

bit-block array wrapped into union for correct interpretation of 32-bit vs 64-bit access vs SIMD

bit-decode cache structure

Structure with statistical information about memory allocation for arena based vectors.

size_t bit_blocks_sz

Total size of bit blocks.

size_t gap_blocks_sz

Total size of gap blocks.

size_t ptr_sub_blocks_sz

Total size of sub-blocks ptrs.

size_t get_alloc_size() const noexcept

Get allocation size in bytes.

unsigned top_block_size

size of top descriptor

void reset() noexcept

Reset statisctics.

Structure with statistical information about memory allocation footprint, serialization projection,...

size_t gap_cap_overhead

gap memory overhead between length and capacity

void add_gap_block(unsigned capacity, unsigned length, unsigned level) noexcept

count gap block

size_t ptr_sub_blocks

Number of sub-blocks.

unsigned long long gaps_by_level[bm::gap_levels]

number of GAP blocks at each level

size_t gap_blocks

Number of GAP blocks.

size_t bit_blocks

Number of bit blocks.

void add(const bv_statistics &st) noexcept

Sum data from another sttructure.

size_t bv_count

Number of bit-vectors.

void add_scorrection() noexcept

add serialization correction (sandbox for override)

void add_bit_block() noexcept

cound bit block

void reset() noexcept

Reset statisctics.

gap_word_t gap_levels[bm::gap_levels]

GAP block lengths in the bvect.

size_t max_serialize_mem

estimated maximum memory for serialization

size_t memory_used

memory usage for all blocks and service tables

Basic stats on second level group of blocks.

bm::gap_word_t bit_blocks

Number of bit blocks.

size_t gap_len_sum

total length of all GAPs

unsigned avg_gap_len() const noexcept

average length of GAP blocks

bm::gap_word_t empty_blocks

how many empty

void init(void *bv, unsigned i) noexcept

unsigned bc_arr[bm::set_sub_array_size]

unsigned gc_arr[bm::set_sub_array_size]

const bm::word_t * blocks[bm::set_sub_array_size]

void * bv_ptr

pointer to bit-vector

bm::gap_word_t gap_blocks

Number of GAP blocks.

unsigned top_level_idx

index of the sub-block of blocks

bool is_only_gaps() const noexcept

true if sub contains multiple gap blocks and nothing else

bm::gap_word_t full_blocks

how many FULL blocks

Alternative GAP lengths table. Good for for memory saver mode and very sparse bitsets.

static bit_operation_count_func_type bit_operation_count(unsigned i)

static gap_operation_to_bitset_func_type gap_op_to_bit(unsigned i)

static bit_operation_count_func_type bit_op_count_table_[bm::set_END]

static gap_operation_func_type gap_operation(unsigned i)

static gap_operation_func_type gapop_table_[bm::set_END]

static gap_operation_to_bitset_func_type gap2bit_table_[bm::set_END]

helper union to interpret pointer as integers


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4