Pixie
Loading...
Searching...
No Matches
wavelet_tree.h
Go to the documentation of this file.
1#pragma once
2
10
11#include <cstddef>
12#include <cstdint>
13#include <vector>
14
15namespace pixie {
16
18enum class WaveletTreeBuildType { Standard, Huffman };
19
26template <class Impl>
28 public:
33 std::size_t size() const { return impl().size_impl(); }
34
39 bool empty() const { return size() == 0; }
40
47 std::size_t rank(std::uint64_t symbol, std::size_t end_position) const {
48 return impl().rank_impl(symbol, end_position);
49 }
50
57 std::size_t select(std::uint64_t symbol, std::size_t rank) const {
58 return impl().select_impl(symbol, rank);
59 }
60
67 std::vector<std::uint64_t> get_segment(std::size_t begin,
68 std::size_t end) const {
69 return impl().get_segment_impl(begin, end);
70 }
71
72 private:
74 const Impl& impl() const { return static_cast<const Impl&>(*this); }
75};
76
77} // namespace pixie
CRTP facade for wavelet-tree queries.
Definition wavelet_tree.h:27
bool empty() const
Check whether the indexed sequence is empty.
Definition wavelet_tree.h:39
std::size_t select(std::uint64_t symbol, std::size_t rank) const
Return the position of the rank-th occurrence of symbol.
Definition wavelet_tree.h:57
std::size_t size() const
Return the number of symbols in the indexed sequence.
Definition wavelet_tree.h:33
std::vector< std::uint64_t > get_segment(std::size_t begin, std::size_t end) const
Reconstruct the sequence range [@p begin, @p end).
Definition wavelet_tree.h:67
std::size_t rank(std::uint64_t symbol, std::size_t end_position) const
Count occurrences of symbol in [0, end_position).
Definition wavelet_tree.h:47
WaveletTreeBuildType
Construction strategy for a wavelet-tree implementation.
Definition wavelet_tree.h:18