8#ifndef INCLUDED_SDSL_RANK_SUPPORT_V
9#define INCLUDED_SDSL_RANK_SUPPORT_V
47template <u
int8_t t_b = 1, u
int8_t t_pat_len = 1>
51 static_assert(t_b == 1u or t_b == 0u or t_b == 10u or t_b == 11,
52 "rank_support_v: bit pattern must be `0`,`1`,`10` or `01`");
53 static_assert(t_pat_len == 1u or t_pat_len == 2u,
"rank_support_v: bit pattern length must be 1 or 2");
84 size_type basic_block_size = (((v->bit_size() + 63) >> 9) + 1) << 1;
85 m_basic_block.
resize(basic_block_size);
86 if (m_basic_block.
empty())
88 uint64_t
const * data =
m_v->
data();
90 m_basic_block[0] = m_basic_block[1] = 0;
94 uint64_t second_level_cnt = 0;
100 m_basic_block[j - 1] = second_level_cnt;
101 m_basic_block[j] = m_basic_block[j - 2] + sum;
102 second_level_cnt = sum = 0;
106 second_level_cnt |= sum << (63 - 9 * (i & 0x7));
112 second_level_cnt |= sum << (63 - 9 * (i & 0x7));
113 m_basic_block[j + 1] = second_level_cnt;
118 m_basic_block[j - 1] = second_level_cnt;
119 m_basic_block[j] = m_basic_block[j - 2] + sum;
120 m_basic_block[j + 1] = 0;
131 assert(
m_v !=
nullptr);
132 assert(idx <= m_v->
size());
133 uint64_t
const * p = m_basic_block.
data() + ((idx >> 8) & 0xFFFFFFFFFFFFFFFEULL);
135 return *p + ((*(p + 1) >> (63 - 9 * ((idx & 0x1FF) >> 6))) & 0x1FF)
138 return *p + ((*(p + 1) >> (63 - 9 * ((idx & 0x1FF) >> 6))) & 0x1FF);
155 written_bytes += m_basic_block.
serialize(out, child,
"cumulative_counts");
157 return written_bytes;
163 m_basic_block.
load(in);
166 template <
typename archive_t>
172 template <
typename archive_t>
180 return m_basic_block == other.m_basic_block;
185 return !(*
this == other);
cereal.hpp offers cereal support
uint64_t const * data() const noexcept
Pointer to the raw data of the int_vector.
bool empty() const noexcept
Equivalent to size() == 0.
size_type bit_size() const noexcept
The number of bits in 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 rank structure proposed by Sebastiano Vigna.
rank_support_v(rank_support_v const &)=default
void load(std::istream &in, int_vector< 1 > const *v=nullptr)
Loads the rank_support.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes rank_support.
rank_support_trait< t_b, t_pat_len > trait_type
rank_support_v(bit_vector const *v=nullptr)
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_v & operator=(rank_support_v const &)=default
bit_vector bit_vector_type
rank_support_v & operator=(rank_support_v &&)=default
bool operator==(rank_support_v const &other) const noexcept
size_type operator()(size_type idx) const
Alias for rank(i)
void set_vector(bit_vector const *v=nullptr)
Sets the supported bit_vector to the given pointer.
rank_support_v(rank_support_v &&)=default
bool operator!=(rank_support_v const &other) const noexcept
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.
bit_vector const * m_v
Pointer to the rank supported bit_vector.
bit_vector::size_type size_type
static structure_tree_node * add_child(structure_tree_node *v, std::string const &name, std::string const &type)
static void add_size(structure_tree_node *v, uint64_t value)
int_vector.hpp contains the sdsl::int_vector class.
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(uint64_t const *, size_type)
static uint64_t init_carry()
static size_type args_in_the_word(uint64_t, uint64_t &)
structure_tree.hpp contains a helper class which can represent the memory structure of a class.
util.hpp contains some helper methods for int_vector and other stuff like demangle class names.