15 template<
typename sa_t>
31 Meta m(
"isa",
"sparse_isa");
41 template<
typename textds_t>
46 static_assert(std::is_same<sa_t, typename textds_t::sa_type>(),
47 "Suffix Array type mismatch!");
50 m_sa = &tds.require_sa(cm);
52 const size_t n = m_sa->size();
60 for(
size_t i = 0; i < n; i++) {
64 size_t j = (*m_sa)[i];
69 m_has_shortcut[j] = 1;
77 if(k > t) m_has_shortcut[i] = 1;
81 m_rank =
Rank(m_has_shortcut);
84 for(
size_t i = 0; i < n; i++) {
87 size_t j = (*m_sa)[i];
89 if(m_has_shortcut[j]) {
90 m_shortcuts[m_rank(j)-1] = i;
97 if(m_has_shortcut[j]) {
98 m_shortcuts[m_rank(j)-1] = i;
112 while((*m_sa)[j] != i) {
113 if(s && m_has_shortcut[j]) {
114 j = m_shortcuts[m_rank(j)-1];
128 return m_has_shortcut.
size();
137 throw std::runtime_error(
"not supported");
142 throw std::runtime_error(
"not supported");
Contains the text compression and encoding framework.
constexpr uint_fast8_t bits_for(size_t n)
Computes the number of bits required to store the given integer value.
A vector over arbitrary unsigned integer types.
const OptionValue & option(const std::string &option) const
Get an option of this algorithm.
Implements a rank data structure for a BitVector.
IntVector< uint_t< 1 > > BitVector
Represents a bit vector, alias for IntVector with a fixed bit width of 1.
uint64_t as_integer() const
SparseISA(Env &&env, textds_t &tds, CompressMode cm)
size_t operator[](size_t i) const
CompressMode
Defines when data structures are bit-compressed.
Env & env()
Provides access to the environment that the algorithm works in.
static ds::InputRestrictions restrictions()
static auto wrap(const char *title, F func) -> typename std::result_of< F(StatPhase &)>::type
Executes a lambda as a single statistics phase.
IntVector< dynamic_t > DynamicIntVector
Represents an integer vector with unspecified (dynamic) bit width.
iv_t copy() const
Creates a copy of the data structure's storage.
Local environment for a compression/encoding/decompression call.
Interface for algorithms.
Constructs the inverse suffix array using the suffix array.
iv_t relinquish()
Forces the data structure to relinquish its data storage.