8 #ifndef INCLUDED_SDSL_RANK_SUPPORT_VFIVE
9 #define INCLUDED_SDSL_RANK_SUPPORT_VFIVE
17 template <u
int8_t, u
int8_t>
18 struct rank_support_trait;
37 template <u
int8_t t_b = 1, u
int8_t t_pat_len = 1>
41 static_assert(t_b == 1u or t_b == 0u or t_b == 10u or t_b == 11u,
42 "rank_support_v5: bit pattern must be `0`,`1`,`10` or `01` or `11`");
43 static_assert(t_pat_len == 1u or t_pat_len == 2u,
"rank_support_v5: bit pattern length must be 1 or 2");
65 if (v ==
nullptr) {
return; }
71 size_type basic_block_size = (((v->bit_size() + 63) >> 11) + 1) << 1;
72 m_basic_block.
resize(basic_block_size);
73 if (m_basic_block.
empty())
return;
74 const uint64_t * data =
m_v->
data();
76 m_basic_block[0] = m_basic_block[1] = 0;
80 uint64_t second_level_cnt = 0;
81 uint64_t cnt_words = 1;
82 for (i = 1; i < ((
m_v->
bit_size() + 63) >> 6); ++i, ++cnt_words)
87 m_basic_block[j - 1] = second_level_cnt;
88 m_basic_block[j] = m_basic_block[j - 2] + sum;
89 second_level_cnt = sum = cnt_words = 0;
91 else if ((cnt_words % 6) == 0)
94 second_level_cnt |= sum << (60 - 12 * (cnt_words / 6));
99 if ((cnt_words % 6) == 0) { second_level_cnt |= sum << (60 - 12 * (cnt_words / 6)); }
103 m_basic_block[j - 1] = second_level_cnt;
104 m_basic_block[j] = m_basic_block[j - 2] + sum;
105 m_basic_block[j + 1] = 0;
109 m_basic_block[j + 1] = second_level_cnt;
120 assert(
m_v !=
nullptr);
121 assert(idx <= m_v->
size());
122 const uint64_t * p = m_basic_block.
data() + ((idx >> 10) & 0xFFFFFFFFFFFFFFFEULL);
124 size_type result = *p + ((*(p + 1) >> (60 - 12 * ((idx & 0x7FF) / (64 * 6)))) & 0x7FFULL) +
127 uint8_t to_do = ((idx >> 6) & 0x1FULL) % 6;
145 written_bytes += m_basic_block.
serialize(out, child,
"cumulative_counts");
147 return written_bytes;
153 m_basic_block.
load(in);
156 template <
typename archive_t>
162 template <
typename archive_t>
bool empty() const noexcept
Equivalent to size() == 0.
size_type bit_size() const noexcept
The number of bits in the int_vector.
const uint64_t * data() const noexcept
Pointer to the raw data of the int_vector.
void load(std::istream &in)
Load the int_vector for a stream.
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.
void resize(const size_type size)
Resize the int_vector in terms of elements.
A class supporting rank queries in constant time.
rank_support_trait< t_b, t_pat_len > trait_type
rank_support_v5 & operator=(rank_support_v5 &&)=default
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes rank_support.
bool operator==(const rank_support_v5 &other) const noexcept
void set_vector(const bit_vector *v=nullptr)
Sets the supported bit_vector to the given pointer.
bool operator!=(const rank_support_v5 &other) const noexcept
size_type rank(size_type idx) const
Answers rank queries for the supported bit_vector.
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
rank_support_v5 & operator=(const rank_support_v5 &)=default
bit_vector bit_vector_type
rank_support_v5(const rank_support_v5 &)=default
rank_support_v5(rank_support_v5 &&)=default
void load(std::istream &in, const bit_vector *v=nullptr)
Loads the rank_support.
size_type operator()(size_type idx) const
Alias for rank(i)
rank_support_v5(const bit_vector *v=nullptr)
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
The base class of classes supporting rank_queries for a sdsl::bit_vector in constant time.
const bit_vector * m_v
Pointer to the rank supported bit_vector.
bit_vector::size_type size_type
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)
Namespace for the succinct data structure library.
rank_support.hpp contains classes that support a sdsl::bit_vector with constant time rank information...
static uint32_t word_rank(const uint64_t *, size_type)
static uint64_t init_carry()
static uint32_t full_word_rank(const uint64_t *, size_type)
static size_type args_in_the_word(uint64_t, uint64_t &)