ucar.unidata.io
Class KMPMatch
java.lang.Object
ucar.unidata.io.KMPMatch
@Immutable
public class KMPMatch
- extends java.lang.Object
Knuth-Morris-Pratt Algorithm for Pattern Matching.
Immutable
- Since:
- May 9, 2008
- Author:
- caron
- See Also:
- http://www.fmi.uni-sofia.bg/fmi/logic/vboutchkova/sources/KMPMatch_java.html
Constructor Summary |
KMPMatch(byte[] match)
Constructor |
Method Summary |
int |
getMatchLength()
|
int |
indexOf(byte[] data,
int start,
int max)
Finds the first occurrence of match in data. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KMPMatch
public KMPMatch(byte[] match)
- Constructor
- Parameters:
match
- search for this byte pattern
getMatchLength
public int getMatchLength()
indexOf
public int indexOf(byte[] data,
int start,
int max)
- Finds the first occurrence of match in data.
- Parameters:
data
- search in this byte blockstart
- start at data[start]max
- end at data[start+max]
- Returns:
- index into data[] of first match, else -1 if not found.