@MinDoc(copyright="Copyright 2010 A. Weinert", author="Albrecht Weinert", version="V.33", lastModified="27.03.2021", usage="make for substrings to search for and use multiply", purpose="Knuth Morris Pratt substring search implementation") public class KMP extends CleverSSS
KMP
object holdsKMP
String
and consorts, are of type O(n*m).making
this KMP
object.super class
.CleverSSS.Simple
Modifier and Type | Field and Description |
---|---|
protected int[] |
kmpSM
The KPM automaton definition.
|
algName, ignoreCase, ignoreWS, len, mskMod, optimisticOK, primF, subC
Modifier | Constructor and Description |
---|---|
protected |
KMP(char[] subC,
int[] kmpSM,
boolean ignoreCase,
boolean ignoreWS,
boolean optimisticOK)
Constructor (for factory methods only, no checks).
|
protected |
KMP(char subOne,
boolean ignoreCase,
boolean ignoreWS)
Constructor (for factory methods only, no checks),
one character only case.
|
Modifier and Type | Method and Description |
---|---|
protected long |
implAlgWhere(CharSequence sequ,
int lk,
int sI,
int mxSi)
The basic implementation of the KMP search algorithm
using this object's settings.
|
protected int |
implAlgWhere(long[] therFnd,
CharSequence sequ,
int lk,
int sI,
int mxSi,
boolean overlap)
The algorithmic implementation of allWhere().
|
static CleverSSS |
make(CharSequence sub,
boolean ignoreCase)
Make a KMP for a subsequence to be searched for.
|
static CleverSSS |
make(CharSequence sub,
boolean ignoreCase,
boolean ignoreWS)
Make a KMP for a subsequence to be searched for (later).
|
String |
state()
The state as String.
|
allWhere, asPair, asPairs, charAt, commonState, compareTo, endIndexOf, endIndexOf, equals, hashCode, indexOf, indexOf, lastIndexOf, lastIndexOf, lastWhereImpl, length, make, make, makeSimple, pair2long, subSequence, toCharA, toString, where, where, whereImpl
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
protected KMP(char[] subC, int[] kmpSM, boolean ignoreCase, boolean ignoreWS, boolean optimisticOK)
protected KMP(char subOne, boolean ignoreCase, boolean ignoreWS)
public static CleverSSS make(CharSequence sub, boolean ignoreCase)
KMP
object for the sub
sequence supplied. That object is suitable for subsequent multiple and
multi-thread searches for that sub
sequence. If (all) that
searches are to ignore case, this has to be (finally) set here.public static CleverSSS make(CharSequence sub, boolean ignoreCase, boolean ignoreWS)
make(CharSequence, boolean)
with the
extra option to make the subsequence search totally white space ignoring
if the the third parameter ignoreWS
is supplied as true.sub
's non blank characters would be transferred
to the KMP
object to be made."al L"
in
" H a l l o "
both ignoring white space and case would
yield 3 as the first matching index (and 8 as the first non matching index
after the fitting sub sequence pattern).public String state()
CleverSSS
CleverSSS
object. The purpose is debugging or fabrication of
often used searches. The result is usually multi line.protected final long implAlgWhere(CharSequence sequ, int lk, int sI, int mxSi)
CleverSSS.whereImpl(CharSequence, int, int)
for
all non trivial cases and with checked / correct parameters.implAlgWhere
in class CleverSSS
sequ
- the sequence to search inlk
- its correct or shortened) lengthsI
- the starting index for the searchmxSi
- the maximum possible value of the match indexCleverSSS.implAlgWhere()
protected int implAlgWhere(long[] therFnd, CharSequence sequ, int lk, int sI, int mxSi, boolean overlap)
allWhere()
after handling all trivial, exceptional, illegal and optimistic
cases.implAlgWhere
in class CleverSSS