9 #ifndef INCLUDED_SDSL_WT_GMR
10 #define INCLUDED_SDSL_WT_GMR
34 template <uint64_t t_s = 32,
37 class t_rank =
typename t_bv::rank_1_type>
50 const iv_type * m_perm =
nullptr;
63 , m_chunksize(chunksize)
71 if (i == off + chunksize)
79 size_type back_pointer = i, j = i, j_new = 0;
80 uint64_t steps = 0, all_steps = 0;
81 while ((j_new = (iv[j] + off)) != i)
89 max_back_pointer = std::max(max_back_pointer, back_pointer - off);
98 max_back_pointer = std::max(max_back_pointer, back_pointer - off);
103 m_marked = t_bv(std::move(marked));
104 util::init_support(m_marked_rank, &m_marked);
112 if (i == off + chunksize)
120 size_type back_pointer = i, j = i, j_new = 0;
121 uint64_t steps = 0, all_steps = 0;
122 while ((j_new = (iv[j] + off)) != i)
130 m_back_pointer[m_marked_rank(j)] = back_pointer - off;
135 if (all_steps > t_s) { m_back_pointer[m_marked_rank(i)] = back_pointer - off; }
143 , m_chunksize(p.m_chunksize)
144 , m_back_pointer(p.m_back_pointer)
145 , m_marked(p.m_marked)
146 , m_marked_rank(p.m_marked_rank)
148 m_marked_rank.set_vector(&m_marked);
160 m_chunksize = p.m_chunksize;
161 m_back_pointer = p.m_back_pointer;
162 m_marked = p.m_marked;
163 m_marked_rank = p.m_marked_rank;
164 m_marked_rank.set_vector(&m_marked);
174 m_perm = std::move(p.m_perm);
175 m_chunksize = std::move(p.m_chunksize);
176 m_back_pointer = std::move(p.m_back_pointer);
177 m_marked = std::move(p.m_marked);
178 m_marked_rank = std::move(p.m_marked_rank);
179 m_marked_rank.set_vector(&m_marked);
197 size_type off = (i / m_chunksize) * m_chunksize;
199 while ((j_new = ((*m_perm)[j]) + off) != i)
203 j = m_back_pointer[m_marked_rank(j)] + off;
204 while ((j_new = ((*m_perm)[j]) + off) != i) j = j_new;
227 written_bytes +=
write_member(m_chunksize, out, child,
"chunksize");
228 written_bytes += m_back_pointer.
serialize(out, child,
"back_pointer");
229 written_bytes += m_marked.serialize(out, child,
"marked");
230 written_bytes += m_marked_rank.serialize(out, child,
"marked_rank");
232 return written_bytes;
240 m_back_pointer.
load(in);
242 m_marked_rank.load(in, &m_marked);
246 template <
typename archive_t>
256 template <
typename archive_t>
263 m_marked_rank.set_vector(&m_marked);
269 return (m_chunksize == other.m_chunksize) && (m_back_pointer == other.m_back_pointer) &&
270 (m_marked == other.m_marked) && (m_marked_rank == other.m_marked_rank);
277 template <
class t_rac>
279 typename std::enable_if<!(std::is_same<t_rac,
int_vector<>>::value), t_rac>::type & rac,
280 const std::string filename)
282 std::string tmp_file_name =
tmp_file(filename,
"_compress_int_vector");
290 template <
class t_rac>
292 typename std::enable_if<std::is_same<t_rac,
int_vector<>>::value, t_rac>::type & rac,
315 template <
class t_rac =
int_vector<>,
316 class t_bitvector = bit_vector,
317 class t_select =
typename t_bitvector::select_1_type,
318 class t_select_zero =
typename t_bitvector::select_0_type>
335 t_bitvector m_bv_blocks;
337 t_select m_bv_blocks_select1;
338 t_select_zero m_bv_blocks_select0;
340 uint64_t m_block_size = 0;
342 uint64_t m_sigma = 0;
359 template <
typename t_it>
364 for (
auto it =
begin; it !=
end; ++it)
367 if (m_block_size < value) m_block_size = value;
372 m_blocks = (m_size + m_block_size - 1) / m_block_size;
373 bit_vector b(m_size + m_block_size * m_blocks + 1, 0);
377 uint64_t j = 0, offset = 0;
378 for (
auto it =
begin; it !=
end; ++it, ++j)
380 if (j == m_block_size)
385 ++tmp[(*it) * m_blocks + offset];
388 for (uint64_t i = 0; i < symbols.
size(); ++i)
390 for (uint64_t j = m_blocks * i; j < (i + 1) * m_blocks; ++j) { symbols[i] += tmp[j]; }
393 for (uint64_t i = 0, l = 1; i < tmp.
size(); ++i, ++l)
395 for (uint64_t j = 0; j < tmp[i]; ++j) b[l++] = 1;
401 for (uint64_t i = 1; i < b.
size(); ++i)
403 if (blocks == m_blocks)
420 m_bv_blocks = t_bitvector(std::move(b));
425 for (uint64_t i = 0, tmp = 0, sum = 0; i < m_block_size; ++i)
433 for (uint64_t j = 0; j < m_block_size and it !=
end; ++it, ++j) { positions[symbols[*it]++] = j; }
435 _transform_to_compressed<t_rac>(positions, m_e, tmp_dir);
437 util::init_support(m_bv_blocks_select0, &m_bv_blocks);
438 util::init_support(m_bv_blocks_select1, &m_bv_blocks);
443 : m_bv_blocks(wt.m_bv_blocks)
445 , m_bv_blocks_select1(wt.m_bv_blocks_select1)
446 , m_bv_blocks_select0(wt.m_bv_blocks_select0)
448 , m_block_size(wt.m_block_size)
449 , m_blocks(wt.m_blocks)
450 , m_sigma(wt.m_sigma)
452 m_bv_blocks_select1.set_vector(&m_bv_blocks);
453 m_bv_blocks_select0.set_vector(&m_bv_blocks);
458 : m_bv_blocks(std::move(wt.m_bv_blocks))
459 , m_e(std::move(wt.m_e))
460 , m_bv_blocks_select1(std::move(wt.m_bv_blocks_select1))
461 , m_bv_blocks_select0(std::move(wt.m_bv_blocks_select0))
463 , m_block_size(wt.m_block_size)
464 , m_blocks(wt.m_blocks)
465 , m_sigma(wt.m_sigma)
467 m_bv_blocks_select1.set_vector(&m_bv_blocks);
468 m_bv_blocks_select0.set_vector(&m_bv_blocks);
475 *
this = std::move(tmp);
482 m_bv_blocks = std::move(wt.m_bv_blocks);
483 m_e = std::move(wt.m_e);
484 m_bv_blocks_select1 = std::move(wt.m_bv_blocks_select1);
485 m_bv_blocks_select1.set_vector(&m_bv_blocks);
486 m_bv_blocks_select0 = std::move(wt.m_bv_blocks_select0);
487 m_bv_blocks_select0.set_vector(&m_bv_blocks);
489 m_block_size = wt.m_block_size;
490 m_blocks = wt.m_blocks;
491 m_sigma = wt.m_sigma;
499 bool empty()
const {
return m_size == 0; }
512 size_type block = i / m_block_size + 1, val = i % m_block_size, search_begin, search_end, j;
515 j = m_bv_blocks_select0(block) + 1;
516 search_begin = j - block;
519 search_end = m_bv_blocks_select0(block + 1) - (block);
520 if (search_end - search_begin < 50)
522 while (search_begin < search_end and m_e[search_begin] <= val)
524 if (m_e[search_begin] == val) {
return (block - 1) / m_blocks; }
530 if (binary_search(m_e.begin() + search_begin, m_e.begin() + search_end, val))
532 return (block - 1) / m_blocks;
552 if (0 == i or c > m_block_size - 1) {
return 0; }
555 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - c * m_blocks;
557 auto begin = m_e.begin() + m_bv_blocks_select0(c * m_blocks + (i - 1) / m_block_size + 1) -
558 (c * m_blocks + (i - 1) / m_block_size + 1) + 1;
559 auto end = m_e.begin() + m_bv_blocks_select0(c * m_blocks + (i - 1) / m_block_size + 2) -
560 (c * m_blocks + (i - 1) / m_block_size + 1);
565 offset = std::find_if(
begin,
end, [&val](
const decltype(*
begin) x) {
return x > val; }) -
begin;
571 return (
begin - m_e.begin()) + offset - ones_before_cblock;
587 size_type block = i / m_block_size + 1, val = i % m_block_size, offset = 0, search_begin, search_end, j;
590 j = m_bv_blocks_select0(block) + 1;
591 search_begin = j - block;
594 search_end = m_bv_blocks_select0(block + 1) - (block);
596 if (search_end - search_begin < 50)
598 while (search_begin < search_end and m_e[search_begin] <= val)
600 if (m_e[search_begin] == val)
603 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks);
604 size_type r = search_begin - ones_before_cblock;
605 return std::make_pair(r, c);
612 offset = lower_bound(m_e.begin() + search_begin, m_e.begin() + search_end, val) - m_e.begin();
613 if (offset < search_end)
615 if (m_e[offset] == val)
618 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks);
619 size_type r = offset - ones_before_cblock;
620 return std::make_pair(r, c);
640 size_type k = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks) + i;
641 return (m_bv_blocks_select1(k) - k) * m_block_size + m_e[k - 1] - c * m_blocks * m_block_size;
649 written_bytes +=
write_member(m_size, out, child,
"size");
650 written_bytes +=
write_member(m_block_size, out, child,
"block_size");
651 written_bytes +=
write_member(m_blocks, out, child,
"blocks");
652 written_bytes +=
write_member(m_sigma, out, child,
"sigma");
653 written_bytes += m_e.serialize(out, child,
"E");
654 written_bytes += m_bv_blocks.serialize(out, child,
"bv_blocks");
655 written_bytes += m_bv_blocks_select0.serialize(out, child,
"bv_blocks_select0");
656 written_bytes += m_bv_blocks_select1.serialize(out, child,
"bv_blocks_select1");
658 return written_bytes;
669 m_bv_blocks.load(in);
670 m_bv_blocks_select0.load(in, &m_bv_blocks);
671 m_bv_blocks_select1.load(in, &m_bv_blocks);
675 template <
typename archive_t>
689 template <
typename archive_t>
699 m_bv_blocks_select0.set_vector(&m_bv_blocks);
701 m_bv_blocks_select1.set_vector(&m_bv_blocks);
712 return (m_size == other.m_size) && (m_block_size == other.m_block_size) && (m_blocks == other.m_blocks) &&
713 (m_sigma == other.m_sigma) && (m_e == other.m_e) && (m_bv_blocks == other.m_bv_blocks) &&
714 (m_bv_blocks_select0 == other.m_bv_blocks_select0) && (m_bv_blocks_select1 == other.m_bv_blocks_select1);
739 template <
class t_rac =
int_vector<>,
740 class t_inverse_support = inv_multi_perm_support<32, t_rac>,
741 class t_bitvector = bit_vector,
742 class t_select =
typename t_bitvector::select_1_type,
743 class t_select_zero =
typename t_bitvector::select_0_type>
760 t_bitvector m_bv_blocks;
761 t_bitvector m_bv_chunks;
764 t_inverse_support m_ips;
766 t_select m_bv_blocks_select1, m_bv_chunks_select1;
767 t_select_zero m_bv_blocks_select0, m_bv_chunks_select0;
770 uint64_t m_max_symbol = 0;
772 uint64_t m_chunksize;
773 uint64_t m_sigma = 0;
790 template <
typename t_it>
795 for (
auto it =
begin; it !=
end; ++it)
798 if (m_max_symbol < value) m_max_symbol = value;
801 m_chunksize = (1ULL << (
bits::hi(m_max_symbol - 1) + 1));
802 m_chunks = (m_size + m_chunksize - 1) / m_chunksize;
806 bit_vector b(m_size + m_max_symbol * m_chunks + 1, 0);
809 uint64_t offset = 0, j = 0;
810 for (
auto it =
begin; it !=
end; ++it, ++j)
812 if (j == m_chunksize)
817 ++tmp[(*it) * m_chunks + offset];
820 for (uint64_t i = 0, l = 1; i < tmp.
size(); ++i, ++l)
821 for (uint64_t j = 0; j < tmp[i]; ++j) b[l++] = 1;
826 for (uint64_t i = 1; i < b.
size(); ++i)
828 if (blocks == m_chunks)
845 m_bv_blocks = t_bitvector(std::move(b));
851 bit_vector x(m_size + m_chunks * m_max_symbol + 1, 0);
855 for (uint64_t i = 0; i < m_chunks; ++i)
860 for (uint64_t j = i * m_chunksize; j < (i + 1) * m_chunksize and j < m_size; ++j)
862 ++symbols[*(
begin + j)];
865 for (uint64_t j = 0; j < m_max_symbol; ++j, ++x_pos)
866 for (uint64_t k = 0; k < symbols[j]; ++k) x[++x_pos] = 1;
869 for (uint64_t j = 0, tmp = 0, sum = 0; j < m_max_symbol; ++j)
876 for (uint64_t j = i * m_chunksize, k = 0; j < (i + 1) * m_chunksize and j < m_size; ++j, ++k)
878 perm[i * m_chunksize + (symbols[*(
begin + j)]++)] = k;
881 m_bv_chunks = t_bitvector(std::move(x));
882 m_ips = t_inverse_support(&m_perm, perm, m_chunksize);
883 _transform_to_compressed<t_rac>(perm, m_perm, tmp_dir);
884 m_ips.set_vector(&m_perm);
886 util::init_support(m_bv_chunks_select1, &m_bv_chunks);
887 util::init_support(m_bv_chunks_select0, &m_bv_chunks);
888 util::init_support(m_bv_blocks_select1, &m_bv_blocks);
889 util::init_support(m_bv_blocks_select0, &m_bv_blocks);
894 : m_bv_blocks(wt.m_bv_blocks)
895 , m_bv_chunks(wt.m_bv_chunks)
898 , m_bv_blocks_select1(wt.m_bv_blocks_select1)
899 , m_bv_chunks_select1(wt.m_bv_chunks_select1)
900 , m_bv_blocks_select0(wt.m_bv_blocks_select0)
901 , m_bv_chunks_select0(wt.m_bv_chunks_select0)
903 , m_max_symbol(wt.m_max_symbol)
904 , m_chunks(wt.m_chunks)
905 , m_chunksize(wt.m_chunksize)
906 , m_sigma(wt.m_sigma)
908 m_ips.set_vector(&m_perm);
909 m_bv_blocks_select1.set_vector(&m_bv_blocks);
910 m_bv_chunks_select1.set_vector(&m_bv_chunks);
911 m_bv_blocks_select0.set_vector(&m_bv_blocks);
912 m_bv_chunks_select0.set_vector(&m_bv_chunks);
917 : m_bv_blocks(std::move(wt.m_bv_blocks))
918 , m_bv_chunks(std::move(wt.m_bv_chunks))
919 , m_perm(std::move(wt.m_perm))
920 , m_ips(std::move(wt.m_ips))
921 , m_bv_blocks_select1(std::move(wt.m_bv_blocks_select1))
922 , m_bv_chunks_select1(std::move(wt.m_bv_chunks_select1))
923 , m_bv_blocks_select0(std::move(wt.m_bv_blocks_select0))
924 , m_bv_chunks_select0(std::move(wt.m_bv_chunks_select0))
926 , m_max_symbol(wt.m_max_symbol)
927 , m_chunks(wt.m_chunks)
928 , m_chunksize(wt.m_chunksize)
929 , m_sigma(wt.m_sigma)
931 m_ips.set_vector(&m_perm);
932 m_bv_blocks_select1.set_vector(&m_bv_blocks);
933 m_bv_chunks_select1.set_vector(&m_bv_chunks);
934 m_bv_blocks_select0.set_vector(&m_bv_blocks);
935 m_bv_chunks_select0.set_vector(&m_bv_chunks);
942 *
this = std::move(tmp);
949 m_bv_blocks = std::move(wt.m_bv_blocks);
950 m_bv_chunks = std::move(wt.m_bv_chunks);
951 m_perm = std::move(wt.m_perm);
952 m_ips = std::move(wt.m_ips);
953 m_ips.set_vector(&m_perm);
954 m_bv_blocks_select1 = std::move(wt.m_bv_blocks_select1);
955 m_bv_blocks_select1.set_vector(&m_bv_blocks);
956 m_bv_chunks_select1 = std::move(wt.m_bv_chunks_select1);
957 m_bv_chunks_select1.set_vector(&m_bv_chunks);
958 m_bv_blocks_select0 = std::move(wt.m_bv_blocks_select0);
959 m_bv_blocks_select0.set_vector(&m_bv_blocks);
960 m_bv_chunks_select0 = std::move(wt.m_bv_chunks_select0);
961 m_bv_chunks_select0.set_vector(&m_bv_chunks);
963 m_max_symbol = wt.m_max_symbol;
964 m_chunks = wt.m_chunks;
965 m_chunksize = wt.m_chunksize;
966 m_sigma = wt.m_sigma;
974 bool empty()
const {
return m_size == 0; }
987 uint64_t chunk = i / m_chunksize;
988 uint64_t x = m_ips[i];
989 return m_bv_chunks_select1(x + 1) - x - (chunk * m_max_symbol) - 1;
1004 assert(i <=
size());
1006 if (0 == i or c > m_max_symbol - 1) {
return 0; }
1008 uint64_t chunk = (i - 1) / m_chunksize;
1009 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks + 1) + 1;
1010 uint64_t c_ones_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk + 1) + 1 -
1013 uint64_t c_ones_in_chunk = 0;
1014 auto begin = m_perm.begin() + m_bv_chunks_select0(chunk * m_max_symbol + 1 + c) -
1015 (chunk * m_max_symbol + 1 + c) + 1;
1016 auto end = m_perm.begin() + m_bv_chunks_select0(chunk * m_max_symbol + 2 + c) - (chunk * m_max_symbol + 2 + c) +
1022 c_ones_in_chunk = std::find_if(
begin,
end, [&val](
const decltype(*
begin) x) {
return x > val; }) -
begin;
1028 return c_ones_before_chunk + c_ones_in_chunk;
1043 uint64_t chunk = i / m_chunksize;
1044 uint64_t x = m_ips[i];
1045 uint64_t tmp = m_bv_chunks_select1(x + 1);
1046 uint64_t c = tmp - x - (chunk * m_max_symbol) - 1;
1048 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks + 1) + 1;
1049 uint64_t c_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk + 1) + 1 -
1051 uint64_t c_in_chunk = tmp - m_bv_chunks_select0(c + 1 + chunk * m_max_symbol) - 1;
1052 return std::make_pair(c_before_chunk + c_in_chunk, c);
1066 assert(1 <= i and i <=
rank(
size(), c));
1068 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks);
1069 uint64_t chunk = m_bv_blocks_select1(ones_before_c + i) - ones_before_c - (c * m_chunks + 1) - i + 1;
1070 uint64_t c_ones_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk) -
1072 uint64_t pi_pos = m_bv_chunks_select0(chunk * m_max_symbol + c + 1) + (i - c_ones_before_chunk) -
1073 chunk * m_max_symbol - c - 1;
1075 return m_perm[pi_pos] + chunk * m_chunksize;
1083 written_bytes +=
write_member(m_size, out, child,
"size");
1084 written_bytes +=
write_member(m_max_symbol, out, child,
"max_symbol");
1085 written_bytes +=
write_member(m_chunks, out, child,
"chunks");
1086 written_bytes +=
write_member(m_chunksize, out, child,
"chunksize");
1087 written_bytes +=
write_member(m_sigma, out, child,
"sigma");
1088 written_bytes += m_bv_blocks.serialize(out, child,
"bv_blocks");
1089 written_bytes += m_bv_blocks_select0.serialize(out, child,
"bv_blocks_select0");
1090 written_bytes += m_bv_blocks_select1.serialize(out, child,
"bv_blocks_select1");
1091 written_bytes += m_bv_chunks.serialize(out, child,
"bv_chunks");
1092 written_bytes += m_bv_chunks_select0.serialize(out, child,
"bv_chunks_select0");
1093 written_bytes += m_bv_chunks_select1.serialize(out, child,
"bv_chunks_select1");
1094 written_bytes += m_perm.serialize(out, child,
"permutation");
1095 written_bytes += m_ips.serialize(out, child,
"inverse_permutation_support");
1097 return written_bytes;
1108 m_bv_blocks.load(in);
1109 m_bv_blocks_select0.load(in, &m_bv_blocks);
1110 m_bv_blocks_select1.load(in, &m_bv_blocks);
1111 m_bv_chunks.load(in);
1112 m_bv_chunks_select0.load(in, &m_bv_chunks);
1113 m_bv_chunks_select1.load(in, &m_bv_chunks);
1115 m_ips.load(in, &m_perm);
1119 template <
typename archive_t>
1138 template <
typename archive_t>
1148 m_bv_blocks_select0.set_vector(&m_bv_blocks);
1150 m_bv_blocks_select1.set_vector(&m_bv_blocks);
1153 m_bv_chunks_select0.set_vector(&m_bv_chunks);
1155 m_bv_chunks_select1.set_vector(&m_bv_chunks);
1158 m_ips.set_vector(&m_perm);
1169 return (m_size == other.m_size) && (m_max_symbol == other.m_max_symbol) && (m_chunks == other.m_chunks) &&
1170 (m_chunksize == other.m_chunksize) && (m_sigma == other.m_sigma) && (m_bv_blocks == other.m_bv_blocks) &&
1171 (m_bv_blocks_select0 == other.m_bv_blocks_select0) &&
1172 (m_bv_blocks_select1 == other.m_bv_blocks_select1) && (m_bv_chunks == other.m_bv_chunks) &&
1173 (m_bv_chunks_select0 == other.m_bv_chunks_select0) &&
1174 (m_bv_chunks_select1 == other.m_bv_chunks_select1) && (m_perm == other.m_perm) && (m_ips == other.m_ips);
bit_vectors.hpp contains classes for uncompressed and compressed bit vector representations.
void close(bool remove_file=false)
Close the int_vector_buffer.
void load(std::istream &in)
Load the int_vector for a stream.
uint8_t width() const noexcept
Returns the width of the integers which are accessed via the [] operator.
size_type size() const noexcept
The number of elements in the int_vector.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the int_vector to a stream.
Class inv_multi_perm_support adds access to the inverse of permutations.
bool operator==(inv_multi_perm_support const &other) const noexcept
Equality operator.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal.
iv_type::size_type size_type
void load(std::istream &in, const iv_type *v=nullptr)
Load sampling from disk.
inv_multi_perm_support(const iv_type *perm, int_vector<> &iv, uint64_t chunksize)
Constructor.
const_iterator begin() const
Returns a const_iterator to the first element.
bool operator!=(inv_multi_perm_support const &other) const noexcept
Inequality operator.
random_access_const_iterator< inv_multi_perm_support > const_iterator
value_type operator[](size_type i) const
Access operator.
inv_multi_perm_support()
Default constructor.
inv_multi_perm_support(const inv_multi_perm_support &p)
Copy constructor.
bool empty() const
Returns whether the original vector contains no data.
iv_type::value_type value_type
inv_multi_perm_support(inv_multi_perm_support &&p)
Move constructor.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serialize into stream.
size_type size() const
Returns the size of the original vector.
inv_multi_perm_support & operator=(const inv_multi_perm_support &p)
Assignment operation.
const_iterator end() const
Returns a const_iterator to the element after the last element.
iv_type::difference_type difference_type
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Load via cereal.
inv_multi_perm_support & operator=(inv_multi_perm_support &&p)
Assignment move operation.
void set_vector(const iv_type *v)
Generic iterator for a random access container.
static void add_size(structure_tree_node *v, uint64_t value)
static structure_tree_node * add_child(structure_tree_node *v, const std::string &name, const std::string &type)
A wavelet tree class for integer sequences.
t_bitvector::difference_type difference_type
const_iterator end() const
size_type select(size_type i, value_type c) const
Calculates the i-th occurrence of the symbol c in the supported vector.
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Load via cereal.
wt_gmr_rs(wt_gmr_rs &&wt)
Move copy constructor.
wt_gmr_rs()=default
Default constructor.
wt_gmr_rs & operator=(const wt_gmr_rs &wt)
Assignment operator.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal.
random_access_const_iterator< wt_gmr_rs > const_iterator
size_type rank(size_type i, value_type c) const
Calculates how many symbols c are in the prefix [0..i-1] of the supported vector.
bool empty() const
Returns whether the wavelet tree contains no data.
int_vector ::value_type value_type
void load(std::istream &in)
Loads the data structure from the given istream.
wt_gmr_rs & operator=(wt_gmr_rs &&wt)
Move assignment operator.
wt_gmr_rs(const wt_gmr_rs &wt)
Copy constructor.
size_type size() const
Returns the size of the original vector.
bool operator==(wt_gmr_rs const &other) const noexcept
Equality operator.
value_type operator[](size_type i) const
Recovers the i-th symbol of the original vector.
wt_gmr_rs(t_it begin, t_it end, std::string tmp_dir=ram_file_name(""))
Construct the wavelet tree from a sequence defined by two interators.
bool operator!=(wt_gmr_rs const &other) const noexcept
Inequality operator.
std::pair< size_type, value_type > inverse_select(size_type i) const
Calculates how many symbols c are in the prefix [0..i-1] of the supported vector.
int_alphabet_tag alphabet_category
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the data structure into the given ostream.
int_vector ::size_type size_type
A wavelet tree class for integer sequences.
bool operator!=(wt_gmr const &other) const noexcept
Inequality operator.
bool empty() const
Returns whether the wavelet tree contains no data.
wt_gmr & operator=(const wt_gmr &wt)
Assignment operator.
wt_gmr()=default
Default constructor.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal.
t_bitvector::difference_type difference_type
bool operator==(wt_gmr const &other) const noexcept
Equality operator.
void load(std::istream &in)
Loads the data structure from the given istream.
wt_gmr(t_it begin, t_it end, std::string tmp_dir=ram_file_name(""))
Construct the wavelet tree from a sequence defined by two interators.
size_type select(size_type i, value_type c) const
Calculates the i-th occurrence of the symbol c in the supported vector.
wt_gmr(wt_gmr &&wt)
Move constructor.
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Load via cereal.
random_access_const_iterator< wt_gmr > const_iterator
size_type rank(size_type i, value_type c) const
Calculates how many symbols c are in the prefix [0..i-1] of the supported vector.
const_iterator end() const
wt_gmr(const wt_gmr &wt)
Copy constructor.
int_alphabet_tag alphabet_category
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the data structure into the given ostream.
std::pair< size_type, value_type > inverse_select(size_type i) const
Calculates how many occurrences of symbol input[i] are in the prefix [0..i-1] of the original input.
wt_gmr & operator=(wt_gmr &&wt)
Move assignment operator.
size_type size() const
Returns the size of the original vector.
value_type operator[](size_type i) const
Recovers the i-th symbol of the original vector.
t_rac::size_type size_type
t_rac::value_type value_type
int_vector.hpp contains the sdsl::int_vector class.
int_vector ::size_type size_type
void set_to_value(t_int_vec &v, uint64_t k)
Set all entries of int_vector to value k.
Namespace for the succinct data structure library.
std::string ram_file_name(const std::string &file)
Returns the corresponding RAM-file name for file.
size_t write_member(const T &t, std::ostream &out, sdsl::structure_tree_node *v=nullptr, std::string name="")
void read_member(T &t, std::istream &in)
std::string tmp_file(const cache_config &config, std::string name_part="")
Returns a name for a temporary file. I.e. the name was not used before.
void _transform_to_compressed(int_vector<> &iv, typename std::enable_if<!(std::is_same< t_rac, int_vector<>>::value), t_rac >::type &rac, const std::string filename)
int_vector< 1 > bit_vector
bit_vector is a specialization of the int_vector.
bool store_to_file(const T &v, const std::string &file)
Store a data structure to a file.
static SDSL_CONSTEXPR uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.