Boyer Screenshot



Boyer

Fast string search (indexOf) using the Boyer-Moorealgorithm. Incorporate this class into your own Javaprograms to rapidly search strings. use:import com.mindprod.Boyer.Boyer;...Boyer b = new Boyer("dogcatwombat");int where = b.indexOf("cat");orint where = Boyer.indexOf("dogcatwombat","cat"); Boyer-Moore is about twice as fast as String.indexOf whenthe string you are searching in is 2K or over and thepattern you are searching for is 4 characters or longer. String.indexOf is particularly slow when the pattern beginswith a common letter such as "e". Boyer-Moore is fastestwhen the pattern is long and composed only of uncommonletters, e.g. "z" or "^". If you use a char[] instead ofString for your text to be searched, it will run anadditional 33% faster. Boyer automatically reverts to String.indexOf when thatwould be faster.


Back to Boyer Details page

New software of Web Authoring, JavaScript