Mercurial > hg > Game > Cerium
changeset 1739:dfeeb2f681db draft
fix BMsearch
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Nov 2013 13:53:29 +0900 |
parents | 893353c014f5 |
children | 5a294d8e5643 e0560291611b |
files | example/regex_mas/ppe/Exec.cc |
diffstat | 1 files changed, 8 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/ppe/Exec.cc Sun Nov 03 19:00:45 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Tue Nov 12 13:53:29 2013 +0900 @@ -1,8 +1,5 @@ #include <stdio.h> #include <string.h> -#include <iostream> -#include <vector> -#include <cstdlib> #include "Exec.h" #include "Func.h" #include "SchedTask.h" @@ -15,26 +12,19 @@ int BM_method(unsigned char *text,int *offset,int *text_length, unsigned char *pattern,unsigned long long *match_string) { - using std::vector; - //int skip[256]; + int skip[256]; int text_len = (long int)text_length; int pattern_len = strlen((char *)pattern); int i = 0; int match_counter = 0; - std::vector<int> vecSkipTable(256,pattern_len); - //for (i = 0; i < 256; ++i){ - // skip[i] = pattern_len; - //} + for (i = 0; i < 256; ++i){ + skip[i] = pattern_len; + } - vecSkipTable[100] = 4; - vecSkipTable[111] = 3; - vecSkipTable[105] = 2; - vecSkipTable[110] = 1; - - //for (i = 0; i < pattern_len-1 ; ++i){ - // skip[(int)pattern[i]] = pattern_len - i - 1; - //} + for (i = 0; i < pattern_len-1 ; ++i){ + skip[(int)pattern[i]] = pattern_len - i - 1; + } @@ -49,8 +39,7 @@ --i; --j; } - //i = i + max((int)skip[(int)text[i]],pattern_len - j); - i = i + max((int)vecSkipTable[(int)text[i]],pattern_len - j); + i = i + max((int)skip[(int)text[i]],pattern_len - j); } return match_counter; }