Class RangePredecessor

Class Documentation

class RangePredecessor

Range-predecessor index over an array of text positions.

Answers “largest value <= limit among A[lb..rb]” in O(log n) time using a wavelet tree over A. It is the structure behind RefPolicy::Last: the candidates for a factor of length L at position i are the suffix-array interval of the factor’s locus node, and the closest non-overlapping one is the largest start <= i - L (forward) or the largest end <= i - 1 (reverse complement) in that interval.

Values >= cap are treated as absent (they are stored as cap and never returned), which keeps the tree at ceil(log2(cap + 1)) levels even when the source array uses a large INF marker.

Queries are read-only and thread-safe.

Public Types

using wt_type = sdsl::wt_int<sdsl::bit_vector, sdsl::rank_support_v5<1>, sdsl::select_support_scan<1>, sdsl::select_support_scan<0>>

Public Functions

RangePredecessor() = default
inline RangePredecessor(const sdsl::int_vector<64> &values, uint64_t cap)
Parameters:
  • values – Array of positions aligned to the suffix array (one entry per SA rank)

  • cap – Smallest value that counts as “absent” (e.g. the text length)

inline bool predecessor(size_t lb, size_t rb, uint64_t limit, uint64_t &out) const

Largest value <= limit in A[lb..rb] (inclusive bounds).

Returns:

true and sets out when such a value exists, false otherwise

inline bool empty() const