net.jxta.search.util
Class KMP
java.lang.Object
|
+--net.jxta.search.util.KMP
- All Implemented Interfaces:
- StringMatcher
- public class KMP
- extends java.lang.Object
- implements StringMatcher
Knuth-Morris-Pratt string-matching algorithm.
Usage:
StringMatcher kmp = new KMP ();
StringMatcher.CompiledPattern pattern = kmp.compile (searchPhrase);
int index = bm.match (text, 0, pattern);
System.out.println ("First location of " + searchPhrase + " at " + index);
Constructor Summary |
KMP()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KMP
public KMP()
main
public static void main(java.lang.String[] argv)
compile
public StringMatcher.CompiledPattern compile(java.lang.String pattern)
- Description copied from interface:
StringMatcher
- Compile the pattern into some algorithm-specific data structure.
- Specified by:
compile
in interface StringMatcher
match
public int match(char[] text,
int textStart,
StringMatcher.CompiledPattern compiledPattern)
- Description copied from interface:
StringMatcher
- Find the first instance of the pattern in the document starting
at index docStart.
- Specified by:
match
in interface StringMatcher