Class FuzzyAlgo
java.lang.Object
org.aesh.readline.fuzzy.FuzzyAlgo
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 Summary
ConstructorsConstructorDescriptionFuzzyAlgo(FuzzyScheme scheme) Create a new FuzzyAlgo instance with the given scoring scheme. -
Method Summary
Modifier and TypeMethodDescriptionmatch(boolean caseSensitive, int[] text, int[] pattern, boolean withPos) Perform fuzzy matching using the optimal algorithm (V2 with V1 fallback).
-
Constructor Details
-
FuzzyAlgo
Create a new FuzzyAlgo instance with the given scoring scheme.- Parameters:
scheme- the scoring scheme
-
-
Method Details
-
match
Perform fuzzy matching using the optimal algorithm (V2 with V1 fallback).- Parameters:
caseSensitive- whether matching is case-sensitivetext- the input text as code pointspattern- the search pattern as code pointswithPos- whether to compute matched character positions- Returns:
- the match result
-