SDSL 3.0.1
Succinct Data Structure Library
rank_support_scan.hpp
Go to the documentation of this file.
1// Copyright (c) 2016, the SDSL Project Authors. All rights reserved.
2// Please see the AUTHORS file for details. Use of this source code is governed
3// by a BSD license that can be found in the LICENSE file.
8#ifndef INCLUDED_SDSL_RANK_SUPPORT_SCAN
9#define INCLUDED_SDSL_RANK_SUPPORT_SCAN
10
11#include <sdsl/rank_support.hpp>
12
13namespace sdsl
14{
15
26template <uint8_t t_b = 1, uint8_t t_pat_len = 1>
28{
29 private:
30 static_assert(t_b == 1u or t_b == 0u or t_b == 10u or t_b == 11u,
31 "rank_support_scan: bit pattern must be `0`,`1`,`10` or `01`");
32 static_assert(t_pat_len == 1u or t_pat_len == 2u, "rank_support_scan: bit pattern length must be 1 or 2");
33
34 public:
36 enum
37 {
38 bit_pat = t_b
39 };
40 enum
41 {
42 bit_pat_len = t_pat_len
43 };
44
45 public:
46 explicit rank_support_scan(const bit_vector * v = nullptr)
47 : rank_support(v){};
48 rank_support_scan(const rank_support_scan & rs) = default;
52 size_type rank(size_type idx) const;
53 size_type operator()(size_type idx) const { return rank(idx); };
54 size_type size() const { return m_v->size(); };
55 size_type serialize(std::ostream & out, structure_tree_node * v = nullptr, std::string name = "") const
56 {
57 return serialize_empty_object(out, v, name, this);
58 }
59 void load(std::istream &, const int_vector<1> * v = nullptr) { set_vector(v); }
60 void set_vector(const bit_vector * v = nullptr) { m_v = v; }
61 template <typename archive_t>
62 void CEREAL_SAVE_FUNCTION_NAME(archive_t &) const
63 {}
64 template <typename archive_t>
65 void CEREAL_LOAD_FUNCTION_NAME(archive_t &)
66 {}
67
69 bool operator==(rank_support_scan const & other) const noexcept { return (*m_v == *other.m_v); }
70
72 bool operator!=(rank_support_scan const & other) const noexcept { return !(*this == other); }
73};
74
75template <uint8_t t_b, uint8_t t_pat_len>
77 size_type idx) const
78{
79 assert(m_v != nullptr);
80 assert(idx <= m_v->size());
81 const uint64_t * p = m_v->data();
82 size_type i = 0;
83 size_type result = 0;
84 while (i + 64 <= idx)
85 {
87 i += 64;
88 }
90}
91
92} // namespace sdsl
93
94#endif // end file
size_type size() const noexcept
The number of elements in the int_vector.
A class supporting rank queries in linear time.
void load(std::istream &, const int_vector< 1 > *v=nullptr)
Loads the rank_support.
rank_support_scan & operator=(rank_support_scan &&rs)=default
rank_support_scan(const rank_support_scan &rs)=default
void CEREAL_LOAD_FUNCTION_NAME(archive_t &)
void set_vector(const bit_vector *v=nullptr)
Sets the supported bit_vector to the given pointer.
void CEREAL_SAVE_FUNCTION_NAME(archive_t &) const
rank_support_scan(const bit_vector *v=nullptr)
size_type operator()(size_type idx) const
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes rank_support.
size_type rank(size_type idx) const
bool operator==(rank_support_scan const &other) const noexcept
Equality operator.
rank_support_scan & operator=(const rank_support_scan &rs)=default
bool operator!=(rank_support_scan const &other) const noexcept
Inequality operator.
rank_support_scan(rank_support_scan &&rs)=default
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
Namespace for the succinct data structure library.
int_vector ::size_type size(const range_type &r)
Size of a range.
Definition: wt_helper.hpp:787
size_t serialize_empty_object(std::ostream &, structure_tree_node *v=nullptr, std::string name="", const T *t=nullptr)
Definition: io.hpp:325
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 uint32_t full_word_rank(const uint64_t *, size_type)