Pixie
Loading...
Searching...
No Matches
wavelet_tree.h
Go to the documentation of this file.
1#pragma once
2
10
11#include <concepts>
12#include <cstddef>
13#include <cstdint>
14#include <vector>
15
16namespace pixie {
17
19enum class WaveletTreeBuildType { Standard, Huffman };
20
22template <class T>
23concept WaveletTreeSymbol = std::unsigned_integral<T> && !std::same_as<T, bool>;
24
35template <class Impl, WaveletTreeSymbol Symbol>
37 public:
42 std::size_t size() const { return impl().size_impl(); }
43
48 bool empty() const { return size() == 0; }
49
56 std::size_t rank(Symbol symbol, std::size_t end_position) const {
57 return impl().rank_impl(symbol, end_position);
58 }
59
66 std::size_t select(Symbol symbol, std::size_t rank) const {
67 return impl().select_impl(symbol, rank);
68 }
69
76 std::vector<Symbol> get_segment(std::size_t begin, std::size_t end) const {
77 return impl().get_segment_impl(begin, end);
78 }
79
80 private:
82 const Impl& impl() const { return static_cast<const Impl&>(*this); }
83};
84
85} // namespace pixie
CRTP facade for wavelet-tree queries.
Definition wavelet_tree.h:36
std::size_t size() const
Return the number of symbols in the indexed sequence.
Definition wavelet_tree.h:42
std::size_t rank(Symbol symbol, std::size_t end_position) const
Count occurrences of symbol in [0, end_position).
Definition wavelet_tree.h:56
std::vector< Symbol > get_segment(std::size_t begin, std::size_t end) const
Reconstruct the sequence range [@p begin, @p end).
Definition wavelet_tree.h:76
std::size_t select(Symbol symbol, std::size_t rank) const
Return the position of the rank-th occurrence of symbol.
Definition wavelet_tree.h:66
bool empty() const
Check whether the indexed sequence is empty.
Definition wavelet_tree.h:48
Unsigned code-unit type indexed by a wavelet tree.
Definition wavelet_tree.h:23
WaveletTreeBuildType
Construction strategy for a wavelet-tree implementation.
Definition wavelet_tree.h:19