Package io.github.connellite.match
Class BMHMatch
java.lang.Object
io.github.connellite.match.BMHMatch
Boyer–Moore–style substring search over
CharSequence.
BMHMatch.Strategy.BAD_CHARACTER uses the bad-character rule only (classic BM shift on mismatch;
after a full match, shift uses the character aligned just past the window when possible).
BMHMatch.Strategy.GOOD_SUFFIX adds strong good-suffix preprocessing (Boyer–Moore style) via
shift/bpos tables.
Both strategies compare UTF-16 code units (CharSequence.charAt(int)), like String.
Time is sublinear on average for long alphabets; worst case depends on the variant.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhich Boyer–Moore-style variantperformBMHSearch(CharSequence, CharSequence, Strategy)uses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisMatch(CharSequence text, CharSequence pattern) performBMHSearch(CharSequence text, CharSequence pattern, BMHMatch.Strategy strategy) Finds all start indices ofpatternintextusing the chosen algorithm.
-
Constructor Details
-
BMHMatch
public BMHMatch()
-
-
Method Details
-
isMatch
- Returns:
trueifpatternoccurs intextat least once- See Also:
-
performBMHSearch
public static List<Integer> performBMHSearch(CharSequence text, CharSequence pattern, BMHMatch.Strategy strategy) Finds all start indices ofpatternintextusing the chosen algorithm.- Parameters:
text- text to search; not nullpattern- substring; not null (empty pattern yields an empty list)strategy- search variant; not null- Returns:
- mutable list of zero-based start indices in ascending order
-