33template <u
int8_t t_w
idth>
52template <
class t_coder = coder::elias_delta<>, u
int32_t t_dens = 128, u
int8_t t_w
idth = 0>
56 static_assert(t_dens > 1,
"vlc_vector: Sampling density must be larger than 1");
77 uint32_t m_sample_dens = t_dens;
84 m_sample_pointer.resize(0);
85 m_sample_pointer.shrink_to_fit();
99 template <
class Container>
103 template <u
int8_t
int_w
idth>
137 return m_size && v.m_size &&
m_z == v.
m_z && m_sample_pointer == v.m_sample_pointer;
142 return !(*
this == v);
152 void load(std::istream & in);
155 template <
typename archive_t>
159 template <
typename archive_t>
169template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
173 return m_sample_dens;
178template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
181 m_sample_dens = sdens;
184template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
191 return (t_coder::template decode<false, false, int *>(
m_z.data(), m_sample_pointer[idx], i - t_dens * idx + 1)) - 1;
194template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
195template <
class Container>
208 throw std::logic_error(
"vlc_vector cannot decode values smaller than 1!");
210 z_size += t_coder::encoding_length(c[i] + 1);
216 m_z.bit_resize(z_size);
218 uint64_t * z_data = t_coder::raw_data(
m_z);
221 for (
size_type i = 0, sample_cnt = 0; i < c.size(); ++i, --no_sample)
226 m_sample_pointer[sample_cnt++] = z_size;
228 t_coder::encode(c[i] + 1, z_data, offset);
229 z_size += t_coder::encoding_length(c[i] + 1);
234template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
235template <u
int8_t
int_w
idth>
249 throw std::logic_error(
"vlc_vector cannot decode values smaller than 1!");
251 z_size += t_coder::encoding_length(x);
259 m_z.bit_resize(z_size);
261 uint64_t * z_data = t_coder::raw_data(
m_z);
266 for (
size_type i = 0, sample_cnt = 0; i < n; ++i, --no_sample)
271 m_sample_pointer[sample_cnt++] = z_size;
274 t_coder::encode(x, z_data, offset);
275 z_size += t_coder::encoding_length(x);
280template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
286 written_bytes +=
write_member(m_size, out, child,
"m_size");
287 written_bytes +=
m_z.serialize(out, child,
"m_z");
288 written_bytes += m_sample_pointer.serialize(out, child,
"m_sample_pointer");
290 return written_bytes;
293template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
298 m_sample_pointer.load(in);
301template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
302template <
typename archive_t>
310template <
class t_coder, u
int32_t t_dens, u
int8_t t_w
idth>
311template <
typename archive_t>
bits.hpp contains the sdsl::bits class.
cereal.hpp offers cereal support
#define CEREAL_LOAD_FUNCTION_NAME
#define CEREAL_SAVE_FUNCTION_NAME
uint64_t size() const
Returns the number of elements currently stored.
A generic vector class for integers of width .
int_vector_size_type size_type
static size_type max_size() noexcept
Maximum size of the int_vector.
Generic iterator for a random access container.
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)
static const uint32_t sample_dens
const const_iterator end() const
Iterator that points to the position after the last element of the vlc_vector.
vlc_vector & operator=(vlc_vector &&)=default
random_access_const_iterator< vlc_vector > iterator
const const_iterator begin() const
Iterator that points to the first element of the vlc_vector.
vlc_vector(vlc_vector &&)=default
bool operator==(vlc_vector const &v) const
vlc_vector_trait< t_width >::int_vector_type int_vector_type
vlc_vector & operator=(vlc_vector const &)=default
size_type size() const
The number of elements in the vlc_vector.
ptrdiff_t difference_type
void load(std::istream &in)
Load the vlc_vector from a stream.
value_type sample(const size_type i) const
Returns the ith sample of vlc_vector.
uint32_t get_sample_dens() const
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Serialise (load) via cereal.
void set_sample_dens(const uint32_t sdens)
const value_type reference
const value_type const_reference
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the vlc_vector to a stream.
int_vector ::size_type size_type
bool operator!=(vlc_vector const &v) const
bool empty() const
Returns if the vlc_vector is empty.
vlc_vector(vlc_vector const &)=default
value_type const * const_pointer
static size_type max_size()
Return the largest size that this container can ever have.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal.
value_type operator[](size_type i) const
[]-operator
coder_elias_delta.hpp contains the class sdsl::coder::elias_delta
int_vector.hpp contains the sdsl::int_vector class.
int_vector_buffer.hpp contains the sdsl::int_vector_buffer class.
io.hpp contains some methods for reading/writing sdsl structures.
iterators.hpp contains an generic iterator for random access containers.
Namespace for the succinct data structure library.
size_t write_member(T const &t, std::ostream &out, sdsl::structure_tree_node *v=nullptr, std::string name="")
void read_member(T &t, std::istream &in)
int_vector< 1 > bit_vector
bit_vector is a specialization of the int_vector.
Contains declarations and definitions of data structure concepts.
static constexpr uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.
int_vector< 32 > int_vector_type
int_vector< 0 > int_vector_type
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.