/*****************************************************
* Boyer Moore Pattern Matching Algorithm
* 20060427 by daineng@nj.cpsecure
*****************************************************/
这个算法的特点在于从pattern的最后一位开始比较,一旦不
符合则把pattern提前到当前比较位置上的元素和pattern中某
个一致为止。
Boyer_Moore的算法说明有很多,但不是很明白,结合下面的
数据将会很容易理解这个算法。(由于字符位置比较重要,
下面的例子需要在等字符宽度的字体下显示才有效果)
抱歉我没有太多的时间说明这个问题。
-------------------------------------------------
1 2 3 4
1234567890123456789012345678901234567890123456789
-------------------------------------------------
This is a test of the Boyer Moore algorithm
algorithm
87654321
>> (sf['a'] - 0) = 8
algorithm
>> (sf['f'] - 0) = 9
algorithm
>> (sf['e'] - 0) = 9
algorithm
>> (sf['a'] - 0 = 8
algorithm
-------------------------------------------------
1 2 3 4
1234567890123456789012345678901234567890123456789
-------------------------------------------------
CooBooooBooooo
Booooo
51111
>> (sf['B'] - 2) = 3
Booooo
>> (sf['B'] - 0) = 5
Booooo
|
xxxxBooooxxxx
Boooo
|
-------------------------------------------------
1 2 3 4
1234567890123456789012345678901234567890123456789
-------------------------------------------------