|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jaxfront.core.util.stringSearch.StringSearch
com.jaxfront.core.util.stringSearch.BoyerMooreHorspool
public class BoyerMooreHorspool
An implementation of Horspool's improved version of the Boyer-Moore String
searching algorithm. See "Practical fast searching in strings" (appeared in
Software - Practice & Experience, 10(6):501-506). Unfortunately,
there seems to be no on-line version of his paper.
This is the second fastest algorithm in this library for the
searchChars
and searchString
. Except for very short
patterns (< 5 characters), it is always faster than any other algorithm
except com.eaio.stringsearch.BoyerMooreHorspoolRaita
and faster than
String.indexOf(java.lang.String)
by more than 5 times for
patterns longer than 24 characters. It's searchBytes
methods are
slightly faster than in the
com.eaio.stringsearch.BoyerMooreHorspoolRaita
algorithm.
This implementation is based on Ricardo
Baeza-Yates' implementation.
Preprocessing: O(m + ∑) time Processing : O(mn) worst case
Constructor Summary | |
---|---|
BoyerMooreHorspool()
Constructor for BoyerMooreHorspool. |
Method Summary | |
---|---|
java.lang.Object |
processBytes(byte[] pattern)
Returns a int array. |
java.lang.Object |
processChars(char[] pattern)
Returns a CharIntMap . |
int |
searchBytes(byte[] text,
int textStart,
int textEnd,
byte[] pattern,
java.lang.Object processed)
Returns the position in the text at which the pattern was found. |
int |
searchChars(char[] text,
int textStart,
int textEnd,
char[] pattern,
java.lang.Object processed)
Returns the index of the pattern in the text using the pre-processed Object. |
Methods inherited from class com.jaxfront.core.util.stringSearch.StringSearch |
---|
equals, getAllOccurences, hashCode, processString, searchBytes, searchBytes, searchBytes, searchBytes, searchBytes, searchChars, searchChars, searchChars, searchChars, searchChars, searchString, searchString, searchString, searchString, searchString, searchString, toString, toStringBuffer, usesNative, usesReflection |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BoyerMooreHorspool()
Method Detail |
---|
public java.lang.Object processBytes(byte[] pattern)
int
array.
processBytes
in class StringSearch
pattern
- the byte
array containing the pattern, may not
be null
com.eaio.stringsearch.StringSearch#processBytes(byte[])
public java.lang.Object processChars(char[] pattern)
CharIntMap
.
processChars
in class StringSearch
pattern
- a char
array containing the pattern, may not be
null
com.eaio.stringsearch.StringSearch#processChars(char[])
public int searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, java.lang.Object processed)
StringSearch
searchBytes
in class StringSearch
text
- text the byte
array containing the text, may
not be null
textStart
- at which position in the text the comparing should starttextEnd
- at which position in the text comparing should stoppattern
- the pattern to search for, may not be null
processed
- an Object as returned from StringSearch.processBytes(byte[])
, may
not be null
com.eaio.stringsearch.StringSearch#searchBytes(byte[], int, int,
byte[], java.lang.Object)
public int searchChars(char[] text, int textStart, int textEnd, char[] pattern, java.lang.Object processed)
StringSearch
searchChars
in class StringSearch
text
- the String containing the text, may not be null
textStart
- at which position in the text the comparing should starttextEnd
- at which position in the text comparing should stoppattern
- the pattern to search for, may not be null
processed
- an Object as returned from StringSearch.processChars(char[])
or
StringSearch.processString(String)
, may not be null
com.eaio.stringsearch.StringSearch#searchChars(char[], int, int,
char[], Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |