<
typenameCharType,
typenameBV,
unsignedSTR_SIZE>
79 typedef typenamebvector_type::size_type
size_type;
151{
return bool(*
this) ==
bool(ref); }
180 constvalue_type* v = this->
buf_.
data();
197{
return bool(*
this) ==
bool(ref); }
261{
return(
pos_== it.pos_) && (
sv_== it.sv_); }
265{
return pos_< it.pos_; }
267{
return pos_<= it.pos_; }
269{
return pos_> it.pos_; }
271{
return pos_>= it.pos_; }
275{
returnthis->
value(); }
279{ this->
advance();
return*
this; }
287 constvalue_type*
value()
const;
367bi.buf_matrix_.rows(), bi.buf_matrix_.cols());
397{ this->
add(v);
return*
this; }
401 template<
typenameStrType>
404this->
add(v.c_str());
return*
this;
471bvector_type::optmode
opt_mode_= bvector_type::opt_compress;
515 if(
this!= &str_sv)
536 if(
this!= &str_sv)
537this->
swap(str_sv);
613 template<
typenameStrType>
648 template<
typenameStrType>
651 if(idx >= this->
size())
652this->
size_= idx+1;
662CharType ch =
str[
i];
667ch = CharType(remap_value);
675bv_null->set_bit_no_check(idx);
683 template<
typenameStrType>
710 template<
typenameStrType>
726 template<
typenameStrType>
730 for(
unsigned i= 0;
true; ++
i)
738 unsigned charremap_value = remap_row[unsigned(ch)];
745ch = CharType(remap_value);
800 template<
boolUSE_PREFIX_BUF = false>
1119 template<
typenameCharMatrix>
1123 boolzero_mem =
true)
const 11270,
unsigned(str_len-1), zero_mem);
1143 template<
typenameCharMatrix>
1147 unsignedsubstr_from,
1149 boolzero_mem =
true)
const 1155 structsv_decode_visitor_func
1157sv_decode_visitor_func(CharMatrix& cmatr)
BMNOEXCEPT2 1170 const unsigned i= substr_i_;
1177}
while(++j < bits_size);
1185 autobase = bv_offset - sv_off_;
1187 const unsigned i= substr_i_;
1200 unsignedsubstr_i_= 0;
1213 if(max_sz < dec_size)
1215 if(rows < dec_size)
1220sv_decode_visitor_func func(cmatr);
1222 for(
unsigned i= substr_from;
i<= substr_to; ++
i)
1225func.substr_i_ =
i- substr_from;
1228 for(
unsignedk =
i* 8; k < (
i* 8) + 8; ++k, ++bi)
1238func.sv_off_ = idx_from;
1249 for(
unsigned i= 0;
i< dec_size; ++
i)
1267 template<
typenameCharMatrix>
1272 if(idx_from < this->
size_)
1275this->
clear_range(idx_from, idx_from + imp_size - 1);
1288 template<
typenameCharMatrix>
1379 template<
typenameCharMatrix,
size_tBufSize = ins_buf_size>
1382 boolset_not_null =
true)
1386 unsignedmax_str_size = 0;
1388 for(
unsignedj = 0; j < imp_size; ++j)
1391 typenameCharMatrix::size_type
i;
1392 typenameCharMatrix::size_type cols = cmatr.cols();
1393 for(
i= 0;
i< cols; ++
i)
1399(unsigned)((
i> max_str_size) ?
i: max_str_size);
1404 unsigned charremap_value =
1410 str[
i] = CharType(remap_value);
1418unsigned_value_type ch_slice[BufSize];
1419 for(
unsigned i= 0;
i< max_str_size; ++
i)
1421 unsignedch_acc = 0;
1422 #if defined(BMVECTOPT) || defined(BM_USE_GCC_BUILD) 1425 for(
size_typej = 0; j < imp_size; j+=4)
1433ch_slice[j] =
ch0; ch_slice[j+1] =
ch1;
1434ch_slice[j+2] =
ch2; ch_slice[j+3] =
ch3;
1440 for(
size_typej = 0; j < imp_size; ++j)
1450 size_typeidx_to = idx_from + imp_size - 1;
1454bv_null->set_range(idx_from, idx_to);
1456 if(idx_to >= this->
size())
1457this->
size_= idx_to+1;
1461 #pragma warning( push ) 1462 #pragma warning( disable : 4146 ) 1465 template<
size_tBufSize = ins_buf_size>
1472 for( ;ch_acc; ch_acc &= ch_acc - 1)
1474 unsignedn_bits = 0;
1476 unsigned mask= 1u << bi;
1477 #if defined(BMVECTOPT) || defined(BM_USE_GCC_BUILD) 1481 for(
size_typej = 0; j < imp_size; j+=4)
1483 unsigned ch0= ((unsigned)ch_slice[j+0]) |
1484((unsigned)ch_slice[j+1] << 8) |
1485((unsigned)ch_slice[j+2] << 16) |
1486((unsigned)ch_slice[j+3] << 24);
1489(
ch0>> (bi+14)) | (
ch0>> (bi+21));
1494 const unsignedbit_idx =
1496 bit_list[n_bits++] = base_idx + bit_idx;
1503 for(
size_typej = 0; j < imp_size; ++j)
1505 unsignedch = unsigned(ch_slice[j]);
1507 bit_list[n_bits++] = idx_from + j;
1515bv->import_sorted(&
bit_list[0], n_bits,
false);
1520 #pragma warning( pop ) 1573*idx_from = from; *idx_to = to;
return true;
1584 void remap(back_insert_iterator& iit);
1607 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1616static_assert(STR_SIZE > 1,
1617 "BM:: String vector size must be > 1 (to accomodate 0 terminator)");
1623 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1627remap_flags_(str_sv.remap_flags_),
1628remap_matrix1_(str_sv.remap_matrix1_),
1629remap_matrix2_(str_sv.remap_matrix2_)
1631static_assert(STR_SIZE > 1,
1632 "BM:: String vector size must be > 1 (to accomodate 0 terminator)");
1637 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1641remap_flags_(str_sv.remap_flags_),
1642remap_matrix1_(str_sv.remap_matrix1_),
1643remap_matrix2_(str_sv.remap_matrix2_)
1647static_assert(STR_SIZE > 1,
1648 "BM:: String vector size must be > 1 (to accomodate 0 terminator)");
1654 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1660remap_matrix1_.swap(str_sv.remap_matrix1_);
1661remap_matrix2_.swap(str_sv.remap_matrix2_);
1666 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1670 if(idx >= this->
size())
1671this->size_ = idx+1;
1672set_value(idx,
str);
1677 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1681 if(idx >= this->
size())
1683this->size_ = idx+1;
1684set_value(idx,
str);
1687insert_value(idx,
str);
1693 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1700this->swap_elements(idx1, idx2);
1705 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1709 if(idx >= this->size_)
1711this->erase_column(idx,
true);
1717 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1720 if(idx >= this->size_)
1721this->size_ = idx + 1;
1723this->bmatr_.clear_column(idx, 0);
1727 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1734this->size_ +=
count;
1739 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1743set_value_no_null(idx,
str);
1745bv_null->set_bit_no_check(idx);
1750 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1754 for(
unsigned i= 0;
true; ++
i)
1756CharType ch =
str[
i];
1759this->clear_value_planes_from(
i*8, idx);
1764 auto r= remap_matrix2_.rows();
1767remap_matrix1_.resize(
i+ 1, remap_matrix1_.cols(),
true);
1768remap_matrix2_.resize(
i+ 1, remap_matrix2_.cols(),
true);
1770 unsigned charremap_value = remap_matrix2_.get(
i,
unsigned(ch));
1774this->clear_value_planes_from(
i*8, idx);
1777ch = CharType(remap_value);
1779this->bmatr_.set_octet(idx,
i, (
unsigned char)ch);
1785 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1789insert_value_no_null(idx,
str);
1790this->insert_null(idx,
true);
1795 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1799 for(
unsigned i= 0;
true; ++
i)
1801CharType ch =
str[
i];
1804this->insert_clear_value_planes_from(
i*8, idx);
1810 unsigned charremap_value = remap_matrix2_.get(
i,
unsigned(ch));
1814this->insert_clear_value_planes_from(
i*8, idx);
1817ch = CharType(remap_value);
1819this->bmatr_.insert_octet(idx,
i, (
unsigned char)ch);
1826 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1832 for(;
true; ++
i)
1836CharType ch = CharType(this->bmatr_.get_octet(idx,
i));
1842remap_matrix1_.remap(
str,
i);
1848 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1851 typenamebvector_type::optmode opt_mode,
1854 typenamebvector_type::statistics stbv;
1855parent_type::optimize(temp_block, opt_mode, &stbv);
1863 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1869 typenamebvector_type::statistics stbv;
1870parent_type::calc_stat(&stbv);
1874 st->bit_blocks += stbv.bit_blocks;
1875 st->gap_blocks += stbv.gap_blocks;
1876 st->ptr_sub_blocks += stbv.ptr_sub_blocks;
1877 st->bv_count += stbv.bv_count;
1878 st->max_serialize_mem += stbv.max_serialize_mem + 8;
1879 st->memory_used += stbv.memory_used;
1880 st->gap_cap_overhead += stbv.gap_cap_overhead;
1882 size_tremap_mem_usage =
sizeof(remap_flags_);
1883remap_mem_usage += remap_matrix1_.get_buffer().mem_usage();
1884remap_mem_usage += remap_matrix2_.get_buffer().mem_usage();
1886 st->memory_used += remap_mem_usage;
1889 st->max_serialize_mem += (remap_mem_usage * 2);
1895 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1901 for(
unsigned i= 0;
true; ++
i)
1903CharType octet2 = str2[
i];
1904CharType octet1 = str1[
i];
1910res = (octet1 > octet2) - (octet1 < octet2);
1919 template<
classCharType,
classBV,
unsignedSTR_SIZE>
1928CharType octet2, octet1;
1931 for(;
i< min_len-3;
i+=4)
1934::memcpy(&i2, &str2[
i],
sizeof(i2));
1935::memcpy(&i1, &str1[
i],
sizeof(i1));
1941res = (octet1 > octet2) - (octet1 < octet2);
1944octet2 = str2[
i+1];
1945octet1 = str1[
i+1];
1946res = (octet1 > octet2) - (octet1 < octet2);
1949octet2 = str2[
i+2];
1950octet1 = str1[
i+2];
1951res = (octet1 > octet2) - (octet1 < octet2);
1954octet2 = str2[
i+3];
1955octet1 = str1[
i+3];
1956res = (octet1 > octet2) - (octet1 < octet2);
1966 for(;
i< min_len; ++
i)
1971res = (octet1 > octet2) - (octet1 < octet2);
1976 for(;
true; ++
i)
1985res = (octet1 > octet2) - (octet1 < octet2);
1995 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2003 for(
unsigned i= 0;
true; ++
i)
2005CharType octet2 =
str[
i];
2006CharType octet1 = (CharType)this->bmatr_.get_octet(idx,
i);
2012 const unsigned char* remap_row = remap_matrix1_.row(
i);
2013CharType remap_value1 = (CharType)remap_row[
unsigned(octet1)];
2015res = (remap_value1 > octet2) - (remap_value1 < octet2);
2024 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2032 for(
unsigned i= 0;
true; ++
i)
2034CharType octet2 =
str[
i];
2035CharType octet1 = (CharType)this->bmatr_.get_octet(idx,
i);
2041res = (octet1 > octet2) - (octet1 < octet2);
2051 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2057 intres = remap_flags_ ? compare_remap(idx,
str)
2058: compare_nomap(idx,
str);
2064 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2075 for(
unsigned i= 0;
true; ++
i)
2078CharType octet2 = (CharType)this->bmatr_.get_octet(idx2,
i);
2079CharType octet1 = (CharType)this->bmatr_.get_octet(idx1,
i);
2085 const unsigned char* remap_row = remap_matrix1_.row(
i);
2086 unsigned charremap_value1 = remap_row[unsigned(octet1)];
2088 unsigned charremap_value2 = remap_row[unsigned(octet2)];
2090res = (remap_value1 > remap_value2) - (remap_value1 < remap_value2);
2097 for(
unsigned i= 0;
true; ++
i)
2099CharType octet2 = (CharType)this->bmatr_.get_octet(idx2,
i);
2100CharType octet1 = (CharType)this->bmatr_.get_octet(idx1,
i);
2106res = (octet1 > octet2) - (octet1 < octet2);
2117 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2118 template<
boolUSE_PREFIX_BUF>
2123 BM_ASSERT(!(prefix_buf && !USE_PREFIX_BUF));
2125CharType
ch1= CharType(this->bmatr_.get_octet(idx1,
i));
2126CharType
ch2= CharType(this->bmatr_.get_octet(idx2,
i));
2129 ifconstexpr(USE_PREFIX_BUF)
2132*prefix_buf++ =
ch1;
2134 for(++
i;
true; ++
i)
2136 ch1= CharType(this->bmatr_.get_octet(idx1,
i));
2137 ch2= CharType(this->bmatr_.get_octet(idx2,
i));
2140 ifconstexpr(USE_PREFIX_BUF)
2141*prefix_buf++ =
ch1;
2150 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2163 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2168 returnthis->bmatr_.octet_size();
2173 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2177 size_typemax_str_len = effective_max_str();
2178octet_matrix.
resize(max_str_len, 256,
false);
2182 for(; it.
valid(); ++it)
2187 for(
unsigned i= 0;
true; ++
i)
2194 unsignedch_idx = (
unsignedchar)ch;
2203 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2209 size_typemax_str_len = effective_max_str();
2210octet_remap_matrix1.
resize(max_str_len, 256,
false);
2212octet_remap_matrix2.
resize(max_str_len, 256,
false);
2215 for(
unsigned i= 0;
i< octet_occupancy_matrix.
rows(); ++
i)
2218octet_occupancy_matrix.
row(
i);
2220 unsigned char* remap_row1 = octet_remap_matrix1.
row(
i);
2221 unsigned char* remap_row2 = octet_remap_matrix2.
row(
i);
2224octet_occupancy_matrix.
cols();
2225 for(
unsignedremap_code = 1;
true; ++remap_code)
2235 unsigned charch = (
unsignedchar)char_idx;
2236remap_row1[remap_code] = ch;
2237remap_row2[ch] = (
unsignedchar)remap_code;
2238frq_row[char_idx] = 0;
2245 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2250 autorows = remap_matrix1_.rows();
2251remap_matrix2_.resize(rows, remap_matrix1_.cols(),
false);
2254remap_matrix2_.set_zero();
2256 for(
unsigned i= 0;
i< remap_matrix1_.rows(); ++
i)
2258 const unsigned char* remap_row1 = remap_matrix1_.row(
i);
2259 unsigned char* remap_row2 = remap_matrix2_.row(
i);
2260 for(
unsignedj = 1; j < remap_matrix1_.cols(); ++j)
2264 unsignedch_code = remap_row1[j];
2265remap_row2[ch_code] = (
unsignedchar)j;
2275 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2282 if(!octet_remap_matrix2.rows())
2285 const unsigned char* remap_row = octet_remap_matrix2.row(0);
2286 for(
unsigned i= 0;
i< buf_size; ++
i, remap_row += 256)
2288CharType ch =
str[
i];
2294 unsigned charremap_value = remap_row[unsigned(ch)];
2295sv_str[
i] = CharType(remap_value);
2304 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2313 BM_ASSERT(in_len <= buf_size); (void) buf_size;
2315 const unsigned char* remap_row = octet_remap_matrix2.row(0);
2316 for(
unsigned i= 0;
i< in_len; ++
i, remap_row += 256)
2318CharType ch =
str[
i];
2321 unsigned charremap_value = remap_row[unsigned(ch)];
2322sv_str[
i] = CharType(remap_value);
2326sv_str[in_len] = str_cp[in_len] = 0;
2333 template<
classCharType,
classBV,
unsignedMAX_STR_SIZE>
2341 const unsigned char* remap_row = octet_remap_matrix1.row(0);
2342 for(
unsigned i= 0;
i< buf_size; ++
i, remap_row += 256)
2344CharType ch = sv_str[
i];
2350 unsigned charremap_value = remap_row[unsigned(ch)];
2351 str[
i] = CharType(remap_value);
2360 template<
classCharType,
classBV,
unsignedMAX_STR_SIZE>
2364sv_tmp(this->get_null_support());
2366sv_tmp.
swap(*
this);
2371 template<
classCharType,
classBV,
unsignedMAX_STR_SIZE>
2378sv_tmp(this->get_null_support());
2380sv_tmp.
swap(*
this);
2388 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2394remap_from_impl(str_sv, omatrix,
false);
2399 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2406 const unsignedbuffer_size = ins_buf_size;
2414 typenamebvector_type::allocator_pool_type pool;
2424pool.set_block_limit(
r+ 10);
2427this->clear_all(
true);
2428 if(str_sv.
empty())
2435omatrix = &occ_matrix;
2443buffer_matrix_type cmatr(buffer_size, str_len);
2448dsize = str_sv.
decode(cmatr,
i, buffer_size,
true);
2451 if(move_data && (dsize == ins_buf_size))
2460this->
import(cmatr,
i, dsize);
2472*bv_null = *bv_null_arg;
2483 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2488recalc_remap_matrix2();
2494 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2504 if(remap_flags_ != sv.remap_flags_)
2512 b= remap_matrix1_.equal_overlap(sv.remap_matrix1_);
2515 b= remap_matrix2_.equal_overlap(sv.remap_matrix2_);
2519 returnparent_type::equal(sv, null_able);
2524 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2532this->clear_all(
true);
2538this->copy_range_slices(sv, left, right, slice_null);
2544 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2550 if(this->size_ < arg_size)
2565this->merge_matr(str_sv.
bmatr_);
2569bv_null->set_range(0, arg_size-1);
2577 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2584this->keep_range_no_check(left, right, slice_null);
2589 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2595 returnit_type(
this);
2600 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2604parent_type::clear_all(free_mem);
2605 if(remap_flags_ && (remap == 0))
2608remap_matrix1_.free();
2609remap_matrix2_.free();
2615 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2617 const char* err_msg)
2620 throwstd::range_error(err_msg);
2628 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2630 const char* err_msg)
2634err_msg =
"Unknown/incomparable dictionary character";
2635 throwstd::domain_error(err_msg);
2647 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2649: sv_(0), substr_from_(0), substr_to_(STR_SIZE),
2656 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2660substr_from_(it.substr_from_), substr_to_(it.substr_to_),
2661pos_(it.pos_), pos_in_buf_(~
size_type(0))
2667 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2673substr_to_ = (unsigned) sv_->effective_max_str();
2674buf_matrix_.resize(n_rows, substr_to_+1);
2679 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2686substr_to_ = (unsigned) sv_->effective_max_str();
2687buf_matrix_.resize(n_rows, substr_to_+1);
2692 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2696 unsigned max_str= sv_->effective_max_str();
2697substr_from_ = from;
2701substr_to_ = from +
len;
2706substr_to_ = substr_from_ + (
len- 1);
2710buf_matrix_.resize(n_rows,
len+1,
false);
2715 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2724 if(!buf_matrix_.is_init())
2727 size_typed = sv_->decode_substr(buf_matrix_, pos_, n_rows,
2728substr_from_, substr_to_);
2737 returnbuf_matrix_.row(pos_in_buf_);
2742 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2751 if(!buf_matrix_.is_init())
2754 size_typed = sv_->decode_substr(buf_matrix_, pos_, n_rows,
2755substr_from_, substr_to_);
2770 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2776pos_ = (!sv_ || pos >= sv_->size()) ?
bm::id_max: pos;
2782 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2790 if(pos_ >= sv_->size())
2797 if(pos_in_buf_ >= n_rows)
2807 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2809: sv_(0), bv_null_(0), pos_in_buf_(~
size_type(0))
2814 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2822bv_null_ = sv_->get_null_bvect();
2823 unsignedesize = (unsigned) sv_->effective_max_str();
2824 if(esize < STR_SIZE)
2826buf_matrix_.init_resize(n_buf_size, esize);
2830bv_null_ = 0; prev_nb_ = 0;
2836 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2839: sv_(bi.sv_), bv_null_(bi.bv_null_), buf_matrix_(bi.buf_matrix_.rows(), bi.buf_matrix_.cols()),
2840pos_in_buf_(~
size_type(0)), prev_nb_(bi.prev_nb_), opt_mode_(bi.opt_mode_),
2848 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2856 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2861 return(pos_in_buf_ == ~
size_type(0) || !sv_);
2866 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2873sv_->remap(*
this);
2880 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2883 if(this->
empty())
2886size_type imp_idx = sv_->size();
2887sv_->import_no_check(buf_matrix_, imp_idx, pos_in_buf_+1,
false);
2892sv_->optimize_block(prev_nb_, opt_mode_);
2900 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2914bv_null_->set_bit_no_check(sz + buf_idx + 1);
2919 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2922this->add_value(
"");
2927 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2932this->add_value(
"");
2938 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2945 size_tslen = ::strlen(v);
2947 autoorows = omatrix_.rows();
2952omatrix_.resize(slen, 256,
false);
2953omatrix_.set_zero();
2957omatrix_.resize(slen, 256,
true);
2958 for(; orows < omatrix_.rows(); ++orows)
2962::memset(
r, 0, 256 *
sizeof(
r[0]));
2966 for(
size_t i= 0;
i< slen; ++
i)
2971 unsignedch_idx = (
unsignedchar)ch;
2978 template<
classCharType,
classBV,
unsignedSTR_SIZE>
2987 if(pos_in_buf_ >= buf_matrix_.rows()-1)
2989 if(pos_in_buf_ == ~
size_type(0) && (!buf_matrix_.is_init()))
2993pos_in_buf_ = 0; buf_matrix_.set_zero();
3007 for(
i= 0;
i< cols; ++
i)
3015 for(cols =
i;
true; ++cols)
3022buf_matrix_.
resize(buf_matrix_.rows(), cols + 1);
3024 r= buf_matrix_.row(pos_in_buf_);
3025cols = buf_matrix_.cols();
3026 for(;
i< cols; ++
i)
3037 template<
classCharType,
classBV,
unsignedSTR_SIZE>
3043 boolfound = bv_null->find_reverse(this->
size_);
3044this->
size_+= found;
ncbi::TMaskedQueryRegions mask
Algorithms for bvector<> (main include)
basic bit-matrix class and utilities
Constants, lookup tables and typedefs.
#define BM_ASSERT_THROW(x, xerrcode)
Utilities for bit transposition (internal) (experimental!)
void assign_if_not_set(POOL &pool, PCLASS &obj) BMNOEXCEPT
check if vector has no assigned allocator and set one
Base class for bit-transposed(bit-sliced) sparse vector construction.
void freeze_matr()
Turn on RO mode.
void resize(size_type new_size, bool set_null)
const bmatrix_type & get_bmatrix() const noexcept
const value_type & const_reference
void copy_from(const base_sparse_vector< CharType, BV, MAX_SIZE > &bsv)
void clear_range(size_type left, size_type right, bool set_null)
bvector_type_ptr get_create_slice(unsigned i)
get access to bit-plain, function checks and creates a plane
bool is_nullable() const noexcept
check if container supports NULL(unassigned) values
bool is_null(size_type idx) const noexcept
test if specified element is NULL
bmatrix_type bmatr_
bit-transposed matrix
void swap(base_sparse_vector< CharType, BV, MAX_SIZE > &bsv) noexcept
size_type size_
array size
void bit_and_rows(const bvector_type &bv)
Set AND (intersect) operation on all existing bit-slices.
std::make_unsigned< value_type >::type unsigned_value_type
void bit_sub_rows(const bvector_type &bv, bool use_null)
Set SUB (MINUS) operation on all existing bit-slices.
const bvector_type * get_null_bvector() const noexcept
Get bit-vector of assigned values or NULL (if not constructed that way)
bvector_type * get_null_bvect() noexcept
void clear_value_planes_from(unsigned plane_idx, size_type idx)
Basic dense bit-matrix class.
bool is_ro() const noexcept
return true if matrix is in read-only mode
unsigned char get_octet(size_type pos, size_type octet_idx) const noexcept
size_type rows_not_null() const noexcept
void allocate_rows(size_type rsize)
allocate matrix rows of bit-vectors (new rows are NULLs)
bvector_type_const_ptr get_row(size_type i) const noexcept
void set_octet(size_type pos, size_type octet_idx, unsigned char octet)
size_type rows() const noexcept
unsigned char * data() noexcept
Get write access to buffer memory.
size_t size() const noexcept
Get buffer size.
const unsigned char * buf() const noexcept
Get read access to buffer memory.
const value_type * row(size_type row_idx) const noexcept
buffer_type & get_buffer() noexcept
Get low-level buffer access.
void swap(dynamic_heap_matrix &other) noexcept
value_type get(size_type row_idx, size_type col_idx) noexcept
size_type rows() const noexcept
size_type cols() const noexcept
void remapz(VECT_TYPE *vect) const noexcept
void set_zero() noexcept
memset all buffer to all zeroes
void init_resize(size_type rows_in, size_type cols_in)
void resize(size_type rows_in, size_type cols_in, bool copy_content=true)
void init(bool set_z=false)
Post construction allocation, initialization.
value_type * data() const noexcept
void resize(size_type new_size)
vector resize
sparse vector de-serializer
Serialize sparse vector into a memory buffer(s) structure.
Back insert iterator implements buffered insert, faster than generic access assignment.
bvector_type * bv_null_
!< pointer on the parent vector
back_insert_iterator & operator*()
noop
void add_remap_stat(const value_type *v)
account new value as remap statistics
void add(const value_type *v)
add value to the container
size_type pos_in_buf_
!< value buffer
octet_freq_matrix_type omatrix_
octet frequency matrix
void add_value(const value_type *v)
add value to the buffer without changing the NULL vector
back_insert_iterator & operator++()
noop
void flush()
flush the accumulated buffer.
unsigned remap_flags_
target remapping
void set_remap(bool flag) noexcept
Method to configure back inserter to collect statistics on optimal character codes.
buffer_matrix_type buf_matrix_
!< not NULL vector pointer
back_insert_iterator & operator++(int)
noop
str_sparse_vector_type * str_sparse_vector_type_ptr
bvector_type::block_idx_type block_idx_type
str_sparse_vector_type::value_type value_type
str_sparse_vector_type::size_type size_type
void add_null()
add NULL (no-value) to the container
back_insert_iterator() noexcept
bvector_type::allocator_type allocator_type
back_insert_iterator & operator=(const value_type *v)
push value to the vector
bvector_type::optmode opt_mode_
!< previous block added
bm::dynamic_heap_matrix< CharType, allocator_type > buffer_matrix_type
block_idx_type prev_nb_
!< buffer position
str_sparse_vector< CharType, BV, STR_SIZE > str_sparse_vector_type
std::output_iterator_tag iterator_category
unsigned get_remap() const noexcept
Get curent remap state flags.
void set_optimize(typename bvector_type::optmode opt_mode) noexcept
Set optimization on load option (deafult: false)
const octet_freq_matrix_type & get_octet_matrix() const noexcept
Get octet frequence matrix.
void add_null(size_type count)
add a series of consequitve NULLs (no-value) to the container
str_sparse_vector_type * sv_
allocator_type::allocator_pool_type allocator_pool_type
bool empty() const noexcept
return true if insertion buffer is empty
back_insert_iterator & operator=(const StrType &v)
push value to the vector
str_sparse_vector_type::bvector_type bvector_type
Const iterator to do quick traverse of the sparse vector.
str_sparse_vector_type * str_sparse_vector_type_ptr
std::input_iterator_tag iterator_category
dynamic_heap_matrix< CharType, allocator_type > buffer_matrix_type
bool operator==(const const_iterator &it) const noexcept
bool operator!=(const const_iterator &it) const noexcept
const value_type * operator*() const
Get current position (value)
bool operator<=(const const_iterator &it) const noexcept
const value_type * value() const
Get zero terminated string value at the current position.
allocator_type::allocator_pool_type allocator_pool_type
size_type pos_in_buf_
!< decode value buffer
const_iterator() noexcept
Construct iterator (not attached to any particular vector)
bvector_type::allocator_type allocator_type
void invalidate() noexcept
Invalidate current iterator.
buffer_matrix_type buf_matrix_
!< Position
size_type pos() const noexcept
Current position (index) in the vector.
unsigned substr_from_
!< ptr to parent
unsigned substr_to_
!< substring from
size_type pos_
!< substring to
bool is_null() const noexcept
Get NULL status.
str_sparse_vector< CharType, BV, STR_SIZE > str_sparse_vector_type
void go_to(size_type pos) noexcept
re-position to a specified position
str_sparse_vector_type::bvector_type bvector_type
void set_substr(unsigned from, unsigned len=0) noexcept
setup iterator to retrieve a sub-string of a string
bool operator>=(const const_iterator &it) const noexcept
long long difference_type
const str_sparse_vector_type * sv_
bool operator<(const const_iterator &it) const noexcept
str_sparse_vector_type::size_type size_type
str_sparse_vector_type::value_type value_type
string_view_type get_string_view() const
Get current string as string_view.
void advance() noexcept
advance iterator forward by one
bool valid() const noexcept
Returns true if iterator is at a valid position.
bool operator>(const const_iterator &it) const noexcept
const_iterator & operator++(int) noexcept
Advance to the next available value.
std::basic_string_view< CharType > string_view_type
const_iterator & operator++() noexcept
Advance to the next available value.
Reference class to access elements via common [] operator.
const_reference(const str_sparse_vector< CharType, BV, STR_SIZE > &str_sv, size_type idx)
const str_sparse_vector< CharType, BV, STR_SIZE > & str_sv_
const value_type * get() const noexcept
bool operator==(const const_reference &ref) const noexcept
bool is_null() const noexcept
bm::heap_vector< CharType, typename bvector_type::allocator_type, true > bufffer_type
Reference class to access elements via common [] operator.
str_sparse_vector< CharType, BV, STR_SIZE > & str_sv_
reference(str_sparse_vector< CharType, BV, STR_SIZE > &str_sv, size_type idx)
bool is_null() const noexcept
reference & operator=(const value_type *str)
const value_type * get() const noexcept
bool operator==(const reference &ref) const noexcept
reference & operator=(const reference &ref)
succinct sparse vector for strings with compression using bit-slicing ( transposition) method
void insert(size_type idx, const value_type *str)
insert the specified element
static bool remap_n_tosv_2way(value_type *sv_str, value_type *str_cp, size_type buf_size, const value_type *str, size_t in_len, const slice_octet_matrix_type &octet_remap_matrix2) noexcept
void calc_octet_stat(octet_freq_matrix_type &octet_matrix) const
void clear() noexcept
resize to zero, free memory, reset remapping
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename str_sparse_vector< CharType, BV, STR_SIZE >::statistics *stat=0)
run memory optimization for all vector planes
size_type get(size_type idx, value_type *str, size_type buf_size) const noexcept
get specified element
void set_value(size_type idx, const value_type *str)
set value without checking boundaries
void resize(size_type sz)
resize vector
bool empty() const
return true if vector is empty
static bool remap_tosv(value_type *sv_str, size_type buf_size, const value_type *str, const slice_octet_matrix_type &octet_remap_matrix2) noexcept
void recalc_remap_matrix2()
const_iterator get_const_iterator(size_type idx) const noexcept
Get const_itertor re-positioned to specific element.
int compare_remap(size_type idx, const value_type *str) const noexcept
Variant of compare for remapped vectors.
static constexpr bool is_str() noexcept
bool is_ro() const noexcept
Returns true if vector is read-only.
static size_type max_str()
get maximum string length capacity
unsigned char * init_remap_buffer()
void set_null(size_type idx)
set NULL status for the specified element Vector is resized automatically
void set_null(const bvector_type &bv_idx)
Set NULL all elements set as 1 in the argument vector.
void remap_from_impl(const str_sparse_vector &str_sv, octet_freq_matrix_type *omatrix, bool move_data)
Remap from implementation, please note that move_data flag can violate cosnt-ness.
slice_octet_matrix_type remap_matrix1_
octet remap table 1
const bvector_type * bvector_type_const_ptr
str_sparse_vector< CharType, BV, STR_SIZE > & merge(str_sparse_vector< CharType, BV, STR_SIZE > &str_sv)
merge with another sparse vector using OR operation Merge is different from join(),...
void assign(size_type idx, const StrType &str)
set specified element with bounds checking and automatic resize
bool remap_tosv(value_type *sv_str, size_type buf_size, const value_type *str) const noexcept
str_sparse_vector(bm::null_support null_able=bm::no_null, allocation_policy_type ap=allocation_policy_type(), size_type bv_max_size=bm::id_max, const allocator_type &alloc=allocator_type())
Sparse vector constructor.
bm::dynamic_heap_matrix< unsigned char, allocator_type > slice_octet_matrix_type
Matrix of character remappings.
void remap_from(const str_sparse_vector &str_sv, octet_freq_matrix_type *omatrix=0)
Build remapping profile and load content from another sparse vector Remapped vector likely saves memo...
void sync_size() noexcept
recalculate size to exclude tail NULL elements After this call size() will return the true size of th...
size_type size() const
return size of the vector
void build_octet_remap(slice_octet_matrix_type &octet_remap_matrix1, slice_octet_matrix_type &octet_remap_matrix2, octet_freq_matrix_type &octet_occupancy_matrix) const
void keep(const bvector_type &bv_idx)
Set NULL all elements NOT set as 1 in the argument vector.
void import_char_slice(const unsigned_value_type *ch_slice, unsigned ch_acc, size_type char_slice_idx, size_type idx_from, size_type imp_size)
bool is_remap() const noexcept
Get character remapping status (true | false)
void sync(bool force, bool sync_size)
syncronize internal structures
bm::basic_bmatrix< BV > bmatrix_type
unsigned common_prefix_length(size_type idx1, size_type idx2, value_type *prefix_buf=0) const noexcept
Find size of common prefix between two vector elements in octets.
void insert_value(size_type idx, const value_type *str)
insert value without checking boundaries
CharType * value_type_prt
void push_back(const StrType &str)
push back a string
void import_no_check(CharMatrix &cmatr, size_type idx_from, size_type imp_size, bool set_not_null=true)
bvector_type::allocation_policy allocation_policy_type
void clear(const bvector_type &bv_idx)
Set vector elements spcified by argument bit-vector to empty Note that set to empty elements are NOT ...
void freeze()
Turn sparse vector into immutable mode Read-only (immutable) vector uses less memory and allows faste...
BV::allocator_type allocator_type
void insert_value_no_null(size_type idx, const value_type *str)
insert value without checking boundaries or support of NULL
bm::dynamic_heap_matrix< size_t, allocator_type > octet_freq_matrix_type
Matrix of character frequencies (for optimal code remap)
slice_octet_matrix_type remap_matrix2_
octet remap table 2
bool resolve_range(size_type from, size_type to, size_type *idx_from, size_type *idx_to) const
parent_type::unsigned_value_type unsigned_value_type
void import_back(CharMatrix &cmatr, size_type imp_size)
Bulk push-back import of strings from a C-style matrix of chars.
static int compare_str(const value_type *str1, const value_type *str2) noexcept
size_type decode(CharMatrix &cmatr, size_type idx_from, size_type dec_size, bool zero_mem=true) const
Bulk export strings to a C-style matrix of chars.
void resize_internal(size_type sz)
bool try_get(size_type idx, StrType &str) const
get specified string element if NOT NULL Template method expects an STL-compatible type basic_string<...
bool remap_n_tosv_2way(value_type *sv_str, value_type *str_cp, size_type buf_size, const value_type *str, size_t in_len) const noexcept
void erase(size_type idx)
erase the specified element
size_type effective_size() const noexcept
size of sparse vector (may be different for RSC)
const unsigned char * get_remap_buffer() const
bvector_type * bvector_type_ptr
void insert(size_type idx, const StrType &str)
insert STL string
static void throw_bad_value(const char *err_msg)
throw domain error
void get(size_type idx, StrType &str) const
get specified string element Template method expects an STL-compatible type basic_string<>
reference operator[](size_type idx)
Operator to get write access to an element.
void push_back(const value_type *str)
push back a string (zero terminated)
str_sparse_vector< CharType, BV, STR_SIZE > & operator=(const str_sparse_vector< CharType, BV, STR_SIZE > &str_sv)
static constexpr bool is_compressed() noexcept
various type traits
size_type decode_substr(CharMatrix &cmatr, size_type idx_from, size_type dec_size, unsigned substr_from, unsigned substr_to, bool zero_mem=true) const
Bulk export strings to a C-style matrix of chars.
const remap_matrix_type * get_remap_matrix() const
base_sparse_vector< CharType, BV, STR_SIZE > parent_type
void push_back_null()
push back NULL value
size_type effective_vector_max() const
get effective string length used in vector
static bool remap_fromsv(value_type *str, size_type buf_size, const value_type *sv_str, const slice_octet_matrix_type &octet_remap_matrix1) noexcept
int compare_nomap(size_type idx, const value_type *str) const noexcept
Variant of compare for non-mapped vectors.
void remap()
Build remapping profile and re-load content to save memory.
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
const_iterator begin() const noexcept
Provide const iterator access to container content.
void calc_stat(struct str_sparse_vector< CharType, BV, STR_SIZE >::statistics *st) const noexcept
Calculates memory statistics.
slice_octet_matrix_type remap_matrix_type
bvector_type::enumerator bvector_enumerator_type
void set_value_no_null(size_type idx, const value_type *str)
set value without checking boundaries or support of NULL
void copy_range(const str_sparse_vector< CharType, BV, STR_SIZE > &sv, size_type left, size_type right, bm::null_support slice_null=bm::use_null)
copy range of values from another sparse vector
size_t remap_size() const
bool equal(const str_sparse_vector< CharType, BV, STR_SIZE > &sv, bm::null_support null_able=bm::use_null) const noexcept
check if another sparse vector has the same content and size
static void throw_range_error(const char *err_msg)
throw range error
str_sparse_vector< CharType, BV, STR_SIZE > & clear_range(size_type left, size_type right, bool set_null=false)
clear range (assign bit 0 for all planes)
void swap(size_type idx1, size_type idx2)
swap two vector elements between each other
size_type size_internal() const
void set(size_type idx, const value_type *str)
set specified element with bounds checking and automatic resize
const_iterator end() const noexcept
Provide const iterator access to the end.
unsigned remap_flags_
remapping status
size_type effective_max_str() const noexcept
get effective string length used in vector Calculate and returns efficiency, how close are we to the ...
static bool find_rank(size_type rank, size_type &pos) noexcept
find position of compressed element by its rank
remap_matrix_type * get_remap_matrix()
int compare(size_type idx, const value_type *str) const noexcept
Compare vector element with argument lexicographically.
const const_reference operator[](size_type idx) const
Operator to get read access to an element.
void keep_range(size_type left, size_type right, bm::null_support slice_null=bm::use_null)
Keep only specified interval in the sparse vector, clear all other elements.
str_sparse_vector(str_sparse_vector< CharType, BV, STR_SIZE > &&str_sv) noexcept
allocator_type::allocator_pool_type allocator_pool_type
bvector_type::size_type size_type
void clear_all(bool free_mem, unsigned remap=0) noexcept
resize to zero, free memory
static const char * str(char *buf, int n)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
bm::id_t word_bitcount(bm::id_t w) noexcept
unsigned bit_list(T w, B *bits) noexcept
Unpacks word into list of ON bit indexes.
null_support
NULL-able value support.
@ use_null
support "non-assigned" or "NULL" logic
@ no_null
do not support NULL values
void xor_swap(W &x, W &y) noexcept
XOR swap two variables.
int for_each_bit_range_no_check(const BV &bv, typename BV::size_type left, typename BV::size_type right, Func &bit_functor)
Implementation of for_each_bit_range without boilerplave checks.
bool find_first_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept
Find max non-zero value in an array.
bool find_max_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept
Find max non-zero value in an array.
unsigned long long int id64_t
@ COPY_RTABLES
copy remap tables only (without data)
const unsigned gap_max_bits
const unsigned set_block_shift
bool has_zero_byte_u64(bm::id64_t v) noexcept
Returns true if INT64 contains 0 octet.
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
void resize(vector< SMethodDef > &container)
static const BitmapCharRec ch3
static const BitmapCharRec ch1
static const BitmapCharRec ch0
static const BitmapCharRec ch2
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)
#define row(bind, expected)
Structure with statistical information about memory allocation footprint, serialization projection,...
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