|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectkmp.TextBookKMPMatcher
public class TextBookKMPMatcher
A TextBookKMPMatcher is a KMP matcher using modified code from the Cormen, Leiserson, Rivest, and Stein textbook "Introductuction to Algorithms", 3rd edition. The textbook code is modified in two ways:
This code will not work. The textbook code is designed assuming that array indexing starts at 1. The code needs to be modified for array indexing that starts at 0.
| Constructor Summary | |
|---|---|
TextBookKMPMatcher(java.lang.String pattern)
new KMPMatcher(pattern) returns a string matcher for pattern. |
|
| Method Summary | |
|---|---|
void |
createPrefixFunction()
createPrefixFunction() creates the prefix function for pattern. |
int |
nextMatch()
kmp.nextMatch() returns the position of the next match for kmp's pattern in kmp's text. |
void |
setText(java.lang.String text)
kmp.setText(text) sets the text for kmp to text. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TextBookKMPMatcher(java.lang.String pattern)
pattern - the pattern
java.lang.IllegalArgumentException - if pattern is null or empty| Method Detail |
|---|
private void createPrefixFunction()
public void setText(java.lang.String text)
text - the textpublic int nextMatch()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||