Class FuzzyAlgo

java.lang.Object
org.aesh.readline.fuzzy.FuzzyAlgo

public final class FuzzyAlgo extends Object
Fuzzy matching algorithms ported from fzf's Go implementation.

Two algorithms are provided:

  • V1 (greedy): O(n) forward scan + backward scan. Fast but may not find the highest-scoring alignment. Used as a fallback for very long inputs.
  • V2 (optimal): Modified Smith-Waterman O(nm). Finds the highest-scoring alignment by examining all possible positions. Used for typical inputs.

The instance holds pre-allocated working arrays to avoid per-query allocation. Not thread-safe — use one instance per thread.

See Also:
  • Constructor Details

    • FuzzyAlgo

      public FuzzyAlgo(FuzzyScheme scheme)
      Create a new FuzzyAlgo instance with the given scoring scheme.
      Parameters:
      scheme - the scoring scheme
  • Method Details

    • match

      public FuzzyResult match(boolean caseSensitive, int[] text, int[] pattern, boolean withPos)
      Perform fuzzy matching using the optimal algorithm (V2 with V1 fallback).
      Parameters:
      caseSensitive - whether matching is case-sensitive
      text - the input text as code points
      pattern - the search pattern as code points
      withPos - whether to compute matched character positions
      Returns:
      the match result