Mercurial > hg > Game > Cerium
changeset 1775:72e8c18bfbf6 draft
End moving BMskip_table
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 23 Nov 2013 18:00:06 +0900 |
parents | 39734c8cbcfe |
children | 1c429035e0d1 |
files | example/regex_mas/ppe/Exec.cc |
diffstat | 1 files changed, 8 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/ppe/Exec.cc Sat Nov 23 17:28:22 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Sat Nov 23 18:00:06 2013 +0900 @@ -9,27 +9,15 @@ SchedDefineTask(Exec); //ボイヤームーア法による文字列検索アルゴリズム -static int BM_method(unsigned char *text,int text_length, - unsigned char *pattern,int sw_len) +static int BM_method(unsigned char *text,int text_len, + unsigned char *pattern,int sw_len,int *skip) { - int skip[256]; - int text_len = (long int)text_length; - int pattern_len = sw_len; - int i = 0; + + int i = sw_len - 1; int match_counter = 0; - for (i = 0; i < 256; ++i){ - skip[i] = pattern_len; - } - - for (i = 0; i < pattern_len-1 ; ++i){ - skip[(int)pattern[i]] = pattern_len - i - 1; - } - - i = pattern_len - 1; - while ( i < text_len){ - int j = pattern_len - 1; + int j = sw_len - 1; while (text[i] == pattern[j]){ if (j == 0){ match_counter++; @@ -37,7 +25,7 @@ --i; --j; } - i = i + max((int)skip[(int)text[i]],pattern_len - j); + i = i + max((int)skip[(int)text[i]],sw_len - j); } return match_counter; } @@ -51,17 +39,11 @@ int length = (int)s->get_inputSize(0); int sw_len = (int)s->get_inputSize(1); - - for(int i = 0; i < 256;i++){ - s->printf("skip[%d]:%d\n",i,skip_table[i]); - } - //unsigned char search_word[] = "doing"; - unsigned long long *o_data = (unsigned long long*)wbuf; - o_data[0] = BM_method(i_data,length,search_word,sw_len); + //unsigned char search_word[] = "doing"; + o_data[0] = BM_method(i_data,length,search_word,sw_len,skip_table); //s->printf("in Exec.cc\n"); - return 0; }