Function noLZSS::detail::find_longest_plain_match
Defined in File factorizer_core.hpp
Function Documentation
-
inline PlainMatchResult noLZSS::detail::find_longest_plain_match(const cst_t &cst, const sdsl::rmq_succinct_sct<> &rmq, const RangePredecessor *pred, RefPolicy ref_policy, cst_t::node_type lambda, size_t lambda_node_depth, size_t i)
Finds the longest non-overlapping previous occurrence of the suffix at position i (plain text).
Shared by nolzss() and ParallelFactorizer::factorize_thread() so that both paths select factors identically.
The walk goes from the shallowest non-root ancestor of the current leaf toward the leaf. At each node v (string depth ell) the earliest start jV in v’s SA interval (via rmq) is inspected; v is “fitting” when jV + ell - 1 < i. Let u be the deepest fitting node and v its child on the path:
if the earliest start of v is i itself or min(lcp(i, jV), i - jV) <= depth(u), the factor is node-aligned: length depth(u), and every occurrence of length depth(u) lies in u’s interval;
otherwise the factor ends inside the edge (u, v): length i - jV with jV as its only valid reference (every other suffix of v starts later and would overlap). If u is the root the position becomes a literal.
Reference selection for node-aligned factors follows the policy: RefPolicy::First reports the earliest start in u’s interval (the RMQ minimum); RefPolicy::Last reports the largest start <= i - depth(u) in u’s interval via the range-predecessor index.
- Parameters:
cst – Compressed suffix tree
rmq – RMQ over the suffix array (earliest start per interval)
pred – Range-predecessor index over the suffix array; nullptr unless ref_policy is Last
ref_policy – Reference selection policy
lambda – Leaf of the suffix starting at position i
lambda_node_depth – Node depth of lambda
i – Current position
- Returns:
The factor length and reference to emit at position i