protected static class BaseBytes.ReverseFinder extends BaseBytes.Finder
BaseBytes.Finder
and implements the Boyer-Moore-Horspool
Algorithm adapted for right-to-left search for a pattern in byte arrays.Constructor and Description |
---|
ReverseFinder(PyBuffer pattern)
Construct a ReverseFinder object that may be used (repeatedly) to find matches with the
pattern in text (arrays of bytes).
|
Modifier and Type | Method and Description |
---|---|
protected int[] |
calculateSkipTable()
This method creates a compressed table of bad-character skips from the pattern for
reverse-searching.
|
int |
currIndex()
Return the index in the text array where the preceding pattern match ends (one beyond the
last character matched), which may also be one beyond the effective end ofthe text.
|
int |
nextIndex()
Find the next index in the text array where the pattern starts, but working backwards.
|
public ReverseFinder(PyBuffer pattern)
pattern
- A vew that presents the pattern as an array of bytesprotected int[] calculateSkipTable()
calculateSkipTable
in class BaseBytes.Finder
public int currIndex()
BaseBytes.Finder
nextIndex()
return the start
position.
The following idiom may be used:
f.setText(text); int p = f.nextIndex(); int q = f.currIndex(); // The range text[p:q] is the matched segment.
currIndex
in class BaseBytes.Finder
public int nextIndex()
nextIndex()
return the successive (non-overlapping)
occurrences of the pattern in the text.nextIndex
in class BaseBytes.Finder