9#ifndef INCLUDED_SDSL_WT_GMR
10#define INCLUDED_SDSL_WT_GMR
36template <uint64_t t_s = 32,
39 class t_rank =
typename t_bv::rank_1_type>
52 const iv_type * m_perm =
nullptr;
65 , m_chunksize(chunksize)
73 if (i == off + chunksize)
81 size_type back_pointer = i, j = i, j_new = 0;
82 uint64_t steps = 0, all_steps = 0;
83 while ((j_new = (iv[j] + off)) != i)
91 max_back_pointer = std::max(max_back_pointer, back_pointer - off);
100 max_back_pointer = std::max(max_back_pointer, back_pointer - off);
105 m_marked = t_bv(std::move(marked));
106 util::init_support(m_marked_rank, &m_marked);
114 if (i == off + chunksize)
122 size_type back_pointer = i, j = i, j_new = 0;
123 uint64_t steps = 0, all_steps = 0;
124 while ((j_new = (iv[j] + off)) != i)
132 m_back_pointer[m_marked_rank(j)] = back_pointer - off;
137 if (all_steps > t_s) { m_back_pointer[m_marked_rank(i)] = back_pointer - off; }
145 , m_chunksize(p.m_chunksize)
146 , m_back_pointer(p.m_back_pointer)
147 , m_marked(p.m_marked)
148 , m_marked_rank(p.m_marked_rank)
150 m_marked_rank.set_vector(&m_marked);
162 m_chunksize = p.m_chunksize;
163 m_back_pointer = p.m_back_pointer;
164 m_marked = p.m_marked;
165 m_marked_rank = p.m_marked_rank;
166 m_marked_rank.set_vector(&m_marked);
176 m_perm = std::move(p.m_perm);
177 m_chunksize = std::move(p.m_chunksize);
178 m_back_pointer = std::move(p.m_back_pointer);
179 m_marked = std::move(p.m_marked);
180 m_marked_rank = std::move(p.m_marked_rank);
181 m_marked_rank.set_vector(&m_marked);
199 size_type off = (i / m_chunksize) * m_chunksize;
201 while ((j_new = ((*m_perm)[j]) + off) != i)
205 j = m_back_pointer[m_marked_rank(j)] + off;
206 while ((j_new = ((*m_perm)[j]) + off) != i) j = j_new;
229 written_bytes +=
write_member(m_chunksize, out, child,
"chunksize");
230 written_bytes += m_back_pointer.
serialize(out, child,
"back_pointer");
231 written_bytes += m_marked.serialize(out, child,
"marked");
232 written_bytes += m_marked_rank.serialize(out, child,
"marked_rank");
234 return written_bytes;
242 m_back_pointer.
load(in);
244 m_marked_rank.load(in, &m_marked);
248 template <
typename archive_t>
258 template <
typename archive_t>
265 m_marked_rank.set_vector(&m_marked);
271 return (m_chunksize == other.m_chunksize) && (m_back_pointer == other.m_back_pointer) &&
272 (m_marked == other.m_marked) && (m_marked_rank == other.m_marked_rank);
279template <
class t_rac>
281 typename std::enable_if<!(std::is_same<t_rac,
int_vector<>>::value), t_rac>::type & rac,
282 const std::string filename)
284 std::string tmp_file_name =
tmp_file(filename,
"_compress_int_vector");
292template <
class t_rac>
294 typename std::enable_if<std::is_same<t_rac,
int_vector<>>::value, t_rac>::type & rac,
317template <
class t_rac =
int_vector<>,
318 class t_bitvector = bit_vector,
319 class t_select =
typename t_bitvector::select_1_type,
320 class t_select_zero =
typename t_bitvector::select_0_type>
337 t_bitvector m_bv_blocks;
339 t_select m_bv_blocks_select1;
340 t_select_zero m_bv_blocks_select0;
342 uint64_t m_block_size = 0;
344 uint64_t m_sigma = 0;
361 template <
typename t_it>
366 for (
auto it =
begin; it !=
end; ++it)
369 if (m_block_size < value) m_block_size = value;
374 m_blocks = (m_size + m_block_size - 1) / m_block_size;
375 bit_vector b(m_size + m_block_size * m_blocks + 1, 0);
379 uint64_t j = 0, offset = 0;
380 for (
auto it =
begin; it !=
end; ++it, ++j)
382 if (j == m_block_size)
387 ++tmp[(*it) * m_blocks + offset];
390 for (uint64_t i = 0; i < symbols.
size(); ++i)
392 for (uint64_t j = m_blocks * i; j < (i + 1) * m_blocks; ++j) { symbols[i] += tmp[j]; }
395 for (uint64_t i = 0, l = 1; i < tmp.
size(); ++i, ++l)
397 for (uint64_t j = 0; j < tmp[i]; ++j) b[l++] = 1;
403 for (uint64_t i = 1; i < b.
size(); ++i)
405 if (blocks == m_blocks)
422 m_bv_blocks = t_bitvector(std::move(b));
427 for (uint64_t i = 0, tmp = 0, sum = 0; i < m_block_size; ++i)
435 for (uint64_t j = 0; j < m_block_size and it !=
end; ++it, ++j) { positions[symbols[*it]++] = j; }
437 _transform_to_compressed<t_rac>(positions, m_e, tmp_dir);
439 util::init_support(m_bv_blocks_select0, &m_bv_blocks);
440 util::init_support(m_bv_blocks_select1, &m_bv_blocks);
445 : m_bv_blocks(wt.m_bv_blocks)
447 , m_bv_blocks_select1(wt.m_bv_blocks_select1)
448 , m_bv_blocks_select0(wt.m_bv_blocks_select0)
450 , m_block_size(wt.m_block_size)
451 , m_blocks(wt.m_blocks)
452 , m_sigma(wt.m_sigma)
454 m_bv_blocks_select1.set_vector(&m_bv_blocks);
455 m_bv_blocks_select0.set_vector(&m_bv_blocks);
460 : m_bv_blocks(std::move(wt.m_bv_blocks))
461 , m_e(std::move(wt.m_e))
462 , m_bv_blocks_select1(std::move(wt.m_bv_blocks_select1))
463 , m_bv_blocks_select0(std::move(wt.m_bv_blocks_select0))
465 , m_block_size(wt.m_block_size)
466 , m_blocks(wt.m_blocks)
467 , m_sigma(wt.m_sigma)
469 m_bv_blocks_select1.set_vector(&m_bv_blocks);
470 m_bv_blocks_select0.set_vector(&m_bv_blocks);
477 *
this = std::move(tmp);
484 m_bv_blocks = std::move(wt.m_bv_blocks);
485 m_e = std::move(wt.m_e);
486 m_bv_blocks_select1 = std::move(wt.m_bv_blocks_select1);
487 m_bv_blocks_select1.set_vector(&m_bv_blocks);
488 m_bv_blocks_select0 = std::move(wt.m_bv_blocks_select0);
489 m_bv_blocks_select0.set_vector(&m_bv_blocks);
491 m_block_size = wt.m_block_size;
492 m_blocks = wt.m_blocks;
493 m_sigma = wt.m_sigma;
501 bool empty()
const {
return m_size == 0; }
514 size_type block = i / m_block_size + 1, val = i % m_block_size, search_begin, search_end, j;
517 j = m_bv_blocks_select0(block) + 1;
518 search_begin = j - block;
521 search_end = m_bv_blocks_select0(block + 1) - (block);
522 if (search_end - search_begin < 50)
524 while (search_begin < search_end and m_e[search_begin] <= val)
526 if (m_e[search_begin] == val) {
return (block - 1) / m_blocks; }
532 if (std::binary_search(m_e.begin() + search_begin, m_e.begin() + search_end, val))
534 return (block - 1) / m_blocks;
554 if (0 == i or c > m_block_size - 1) {
return 0; }
557 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - c * m_blocks;
559 auto begin = m_e.begin() + m_bv_blocks_select0(c * m_blocks + (i - 1) / m_block_size + 1) -
560 (c * m_blocks + (i - 1) / m_block_size + 1) + 1;
561 auto end = m_e.begin() + m_bv_blocks_select0(c * m_blocks + (i - 1) / m_block_size + 2) -
562 (c * m_blocks + (i - 1) / m_block_size + 1);
567 offset = std::find_if(
begin,
end, [&val](
const decltype(*
begin) x) {
return x > val; }) -
begin;
573 return (
begin - m_e.begin()) + offset - ones_before_cblock;
589 size_type block = i / m_block_size + 1, val = i % m_block_size, offset = 0, search_begin, search_end, j;
592 j = m_bv_blocks_select0(block) + 1;
593 search_begin = j - block;
596 search_end = m_bv_blocks_select0(block + 1) - (block);
598 if (search_end - search_begin < 50)
600 while (search_begin < search_end and m_e[search_begin] <= val)
602 if (m_e[search_begin] == val)
605 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks);
606 size_type r = search_begin - ones_before_cblock;
607 return std::make_pair(r, c);
614 offset = std::lower_bound(m_e.begin() + search_begin, m_e.begin() + search_end, val) - m_e.begin();
615 if (offset < search_end)
617 if (m_e[offset] == val)
620 size_type ones_before_cblock = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks);
621 size_type r = offset - ones_before_cblock;
622 return std::make_pair(r, c);
642 size_type k = m_bv_blocks_select0(c * m_blocks + 1) - (c * m_blocks) + i;
643 return (m_bv_blocks_select1(k) - k) * m_block_size + m_e[k - 1] - c * m_blocks * m_block_size;
651 written_bytes +=
write_member(m_size, out, child,
"size");
652 written_bytes +=
write_member(m_block_size, out, child,
"block_size");
653 written_bytes +=
write_member(m_blocks, out, child,
"blocks");
654 written_bytes +=
write_member(m_sigma, out, child,
"sigma");
655 written_bytes += m_e.serialize(out, child,
"E");
656 written_bytes += m_bv_blocks.serialize(out, child,
"bv_blocks");
657 written_bytes += m_bv_blocks_select0.serialize(out, child,
"bv_blocks_select0");
658 written_bytes += m_bv_blocks_select1.serialize(out, child,
"bv_blocks_select1");
660 return written_bytes;
671 m_bv_blocks.load(in);
672 m_bv_blocks_select0.load(in, &m_bv_blocks);
673 m_bv_blocks_select1.load(in, &m_bv_blocks);
677 template <
typename archive_t>
691 template <
typename archive_t>
701 m_bv_blocks_select0.set_vector(&m_bv_blocks);
703 m_bv_blocks_select1.set_vector(&m_bv_blocks);
714 return (m_size == other.m_size) && (m_block_size == other.m_block_size) && (m_blocks == other.m_blocks) &&
715 (m_sigma == other.m_sigma) && (m_e == other.m_e) && (m_bv_blocks == other.m_bv_blocks) &&
716 (m_bv_blocks_select0 == other.m_bv_blocks_select0) && (m_bv_blocks_select1 == other.m_bv_blocks_select1);
741template <
class t_rac =
int_vector<>,
742 class t_inverse_support = inv_multi_perm_support<32, t_rac>,
743 class t_bitvector = bit_vector,
744 class t_select =
typename t_bitvector::select_1_type,
745 class t_select_zero =
typename t_bitvector::select_0_type>
762 t_bitvector m_bv_blocks;
763 t_bitvector m_bv_chunks;
766 t_inverse_support m_ips;
768 t_select m_bv_blocks_select1, m_bv_chunks_select1;
769 t_select_zero m_bv_blocks_select0, m_bv_chunks_select0;
772 uint64_t m_max_symbol = 0;
774 uint64_t m_chunksize;
775 uint64_t m_sigma = 0;
792 template <
typename t_it>
797 for (
auto it =
begin; it !=
end; ++it)
800 if (m_max_symbol < value) m_max_symbol = value;
803 m_chunksize = (1ULL << (
bits::hi(m_max_symbol - 1) + 1));
804 m_chunks = (m_size + m_chunksize - 1) / m_chunksize;
808 bit_vector b(m_size + m_max_symbol * m_chunks + 1, 0);
811 uint64_t offset = 0, j = 0;
812 for (
auto it =
begin; it !=
end; ++it, ++j)
814 if (j == m_chunksize)
819 ++tmp[(*it) * m_chunks + offset];
822 for (uint64_t i = 0, l = 1; i < tmp.
size(); ++i, ++l)
823 for (uint64_t j = 0; j < tmp[i]; ++j) b[l++] = 1;
828 for (uint64_t i = 1; i < b.
size(); ++i)
830 if (blocks == m_chunks)
847 m_bv_blocks = t_bitvector(std::move(b));
853 bit_vector x(m_size + m_chunks * m_max_symbol + 1, 0);
857 for (uint64_t i = 0; i < m_chunks; ++i)
862 for (uint64_t j = i * m_chunksize; j < (i + 1) * m_chunksize and j < m_size; ++j)
864 ++symbols[*(
begin + j)];
867 for (uint64_t j = 0; j < m_max_symbol; ++j, ++x_pos)
868 for (uint64_t k = 0; k < symbols[j]; ++k) x[++x_pos] = 1;
871 for (uint64_t j = 0, tmp = 0, sum = 0; j < m_max_symbol; ++j)
878 for (uint64_t j = i * m_chunksize, k = 0; j < (i + 1) * m_chunksize and j < m_size; ++j, ++k)
880 perm[i * m_chunksize + (symbols[*(
begin + j)]++)] = k;
883 m_bv_chunks = t_bitvector(std::move(x));
884 m_ips = t_inverse_support(&m_perm, perm, m_chunksize);
885 _transform_to_compressed<t_rac>(perm, m_perm, tmp_dir);
886 m_ips.set_vector(&m_perm);
888 util::init_support(m_bv_chunks_select1, &m_bv_chunks);
889 util::init_support(m_bv_chunks_select0, &m_bv_chunks);
890 util::init_support(m_bv_blocks_select1, &m_bv_blocks);
891 util::init_support(m_bv_blocks_select0, &m_bv_blocks);
896 : m_bv_blocks(wt.m_bv_blocks)
897 , m_bv_chunks(wt.m_bv_chunks)
900 , m_bv_blocks_select1(wt.m_bv_blocks_select1)
901 , m_bv_chunks_select1(wt.m_bv_chunks_select1)
902 , m_bv_blocks_select0(wt.m_bv_blocks_select0)
903 , m_bv_chunks_select0(wt.m_bv_chunks_select0)
905 , m_max_symbol(wt.m_max_symbol)
906 , m_chunks(wt.m_chunks)
907 , m_chunksize(wt.m_chunksize)
908 , m_sigma(wt.m_sigma)
910 m_ips.set_vector(&m_perm);
911 m_bv_blocks_select1.set_vector(&m_bv_blocks);
912 m_bv_chunks_select1.set_vector(&m_bv_chunks);
913 m_bv_blocks_select0.set_vector(&m_bv_blocks);
914 m_bv_chunks_select0.set_vector(&m_bv_chunks);
919 : m_bv_blocks(std::move(wt.m_bv_blocks))
920 , m_bv_chunks(std::move(wt.m_bv_chunks))
921 , m_perm(std::move(wt.m_perm))
922 , m_ips(std::move(wt.m_ips))
923 , m_bv_blocks_select1(std::move(wt.m_bv_blocks_select1))
924 , m_bv_chunks_select1(std::move(wt.m_bv_chunks_select1))
925 , m_bv_blocks_select0(std::move(wt.m_bv_blocks_select0))
926 , m_bv_chunks_select0(std::move(wt.m_bv_chunks_select0))
928 , m_max_symbol(wt.m_max_symbol)
929 , m_chunks(wt.m_chunks)
930 , m_chunksize(wt.m_chunksize)
931 , m_sigma(wt.m_sigma)
933 m_ips.set_vector(&m_perm);
934 m_bv_blocks_select1.set_vector(&m_bv_blocks);
935 m_bv_chunks_select1.set_vector(&m_bv_chunks);
936 m_bv_blocks_select0.set_vector(&m_bv_blocks);
937 m_bv_chunks_select0.set_vector(&m_bv_chunks);
944 *
this = std::move(tmp);
951 m_bv_blocks = std::move(wt.m_bv_blocks);
952 m_bv_chunks = std::move(wt.m_bv_chunks);
953 m_perm = std::move(wt.m_perm);
954 m_ips = std::move(wt.m_ips);
955 m_ips.set_vector(&m_perm);
956 m_bv_blocks_select1 = std::move(wt.m_bv_blocks_select1);
957 m_bv_blocks_select1.set_vector(&m_bv_blocks);
958 m_bv_chunks_select1 = std::move(wt.m_bv_chunks_select1);
959 m_bv_chunks_select1.set_vector(&m_bv_chunks);
960 m_bv_blocks_select0 = std::move(wt.m_bv_blocks_select0);
961 m_bv_blocks_select0.set_vector(&m_bv_blocks);
962 m_bv_chunks_select0 = std::move(wt.m_bv_chunks_select0);
963 m_bv_chunks_select0.set_vector(&m_bv_chunks);
965 m_max_symbol = wt.m_max_symbol;
966 m_chunks = wt.m_chunks;
967 m_chunksize = wt.m_chunksize;
968 m_sigma = wt.m_sigma;
976 bool empty()
const {
return m_size == 0; }
989 uint64_t chunk = i / m_chunksize;
990 uint64_t x = m_ips[i];
991 return m_bv_chunks_select1(x + 1) - x - (chunk * m_max_symbol) - 1;
1006 assert(i <=
size());
1008 if (0 == i or c > m_max_symbol - 1) {
return 0; }
1010 uint64_t chunk = (i - 1) / m_chunksize;
1011 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks + 1) + 1;
1012 uint64_t c_ones_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk + 1) + 1 -
1015 uint64_t c_ones_in_chunk = 0;
1016 auto begin = m_perm.begin() + m_bv_chunks_select0(chunk * m_max_symbol + 1 + c) -
1017 (chunk * m_max_symbol + 1 + c) + 1;
1018 auto end = m_perm.begin() + m_bv_chunks_select0(chunk * m_max_symbol + 2 + c) - (chunk * m_max_symbol + 2 + c) +
1024 c_ones_in_chunk = std::find_if(
begin,
end, [&val](
const decltype(*
begin) x) {
return x > val; }) -
begin;
1028 c_ones_in_chunk = std::lower_bound(
begin,
end, val + 1) -
begin;
1030 return c_ones_before_chunk + c_ones_in_chunk;
1045 uint64_t chunk = i / m_chunksize;
1046 uint64_t x = m_ips[i];
1047 uint64_t tmp = m_bv_chunks_select1(x + 1);
1048 uint64_t c = tmp - x - (chunk * m_max_symbol) - 1;
1050 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks + 1) + 1;
1051 uint64_t c_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk + 1) + 1 -
1053 uint64_t c_in_chunk = tmp - m_bv_chunks_select0(c + 1 + chunk * m_max_symbol) - 1;
1054 return std::make_pair(c_before_chunk + c_in_chunk, c);
1068 assert(1 <= i and i <=
rank(
size(), c));
1070 uint64_t ones_before_c = m_bv_blocks_select0(c * m_chunks + 1) - (c * m_chunks);
1071 uint64_t chunk = m_bv_blocks_select1(ones_before_c + i) - ones_before_c - (c * m_chunks + 1) - i + 1;
1072 uint64_t c_ones_before_chunk = m_bv_blocks_select0(c * m_chunks + chunk + 1) - (c * m_chunks + chunk) -
1074 uint64_t pi_pos = m_bv_chunks_select0(chunk * m_max_symbol + c + 1) + (i - c_ones_before_chunk) -
1075 chunk * m_max_symbol - c - 1;
1077 return m_perm[pi_pos] + chunk * m_chunksize;
1085 written_bytes +=
write_member(m_size, out, child,
"size");
1086 written_bytes +=
write_member(m_max_symbol, out, child,
"max_symbol");
1087 written_bytes +=
write_member(m_chunks, out, child,
"chunks");
1088 written_bytes +=
write_member(m_chunksize, out, child,
"chunksize");
1089 written_bytes +=
write_member(m_sigma, out, child,
"sigma");
1090 written_bytes += m_bv_blocks.serialize(out, child,
"bv_blocks");
1091 written_bytes += m_bv_blocks_select0.serialize(out, child,
"bv_blocks_select0");
1092 written_bytes += m_bv_blocks_select1.serialize(out, child,
"bv_blocks_select1");
1093 written_bytes += m_bv_chunks.serialize(out, child,
"bv_chunks");
1094 written_bytes += m_bv_chunks_select0.serialize(out, child,
"bv_chunks_select0");
1095 written_bytes += m_bv_chunks_select1.serialize(out, child,
"bv_chunks_select1");
1096 written_bytes += m_perm.serialize(out, child,
"permutation");
1097 written_bytes += m_ips.serialize(out, child,
"inverse_permutation_support");
1099 return written_bytes;
1110 m_bv_blocks.load(in);
1111 m_bv_blocks_select0.load(in, &m_bv_blocks);
1112 m_bv_blocks_select1.load(in, &m_bv_blocks);
1113 m_bv_chunks.load(in);
1114 m_bv_chunks_select0.load(in, &m_bv_chunks);
1115 m_bv_chunks_select1.load(in, &m_bv_chunks);
1117 m_ips.load(in, &m_perm);
1121 template <
typename archive_t>
1140 template <
typename archive_t>
1150 m_bv_blocks_select0.set_vector(&m_bv_blocks);
1152 m_bv_blocks_select1.set_vector(&m_bv_blocks);
1155 m_bv_chunks_select0.set_vector(&m_bv_chunks);
1157 m_bv_chunks_select1.set_vector(&m_bv_chunks);
1160 m_ips.set_vector(&m_perm);
1171 return (m_size == other.m_size) && (m_max_symbol == other.m_max_symbol) && (m_chunks == other.m_chunks) &&
1172 (m_chunksize == other.m_chunksize) && (m_sigma == other.m_sigma) && (m_bv_blocks == other.m_bv_blocks) &&
1173 (m_bv_blocks_select0 == other.m_bv_blocks_select0) &&
1174 (m_bv_blocks_select1 == other.m_bv_blocks_select1) && (m_bv_chunks == other.m_bv_chunks) &&
1175 (m_bv_chunks_select0 == other.m_bv_chunks_select0) &&
1176 (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.
inv_multi_perm_support & operator=(inv_multi_perm_support &&p)
Assignment move operation.
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.
inv_multi_perm_support & operator=(const inv_multi_perm_support &p)
Assignment operation.
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.
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.
void set_vector(const iv_type *v)
Generic iterator for a random access container.
static structure_tree_node * add_child(structure_tree_node *v, const std::string &name, const std::string &type)
static void add_size(structure_tree_node *v, uint64_t value)
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(const wt_gmr_rs &wt)
Copy constructor.
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.
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.
wt_gmr_rs & operator=(wt_gmr_rs &&wt)
Move assignment operator.
bool operator!=(wt_gmr_rs const &other) const noexcept
Inequality operator.
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()=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.
wt_gmr & operator=(const wt_gmr &wt)
Assignment 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
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.
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
wt_gmr & operator=(wt_gmr &&wt)
Move assignment operator.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the data structure into the given ostream.
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.
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 constexpr uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.