Skip to content
Snippets Groups Projects
Commit b9fbd60d authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fixes in knuth morris pratt algo

parent 5c11d751
No related branches found
No related tags found
No related merge requests found
Pipeline #43619 canceled
...@@ -31,7 +31,7 @@ ext::vector<size_t> BorderArray::construct(const string::LinearString < SymbolTy ...@@ -31,7 +31,7 @@ ext::vector<size_t> BorderArray::construct(const string::LinearString < SymbolTy
const auto& w = string.getContent(); const auto& w = string.getContent();
ext::vector<size_t> res(w.size() + 1); ext::vector<size_t> res(w.size() + 1);
   
res[0] = 0; res[0] = -1;
res[1] = 0; res[1] = 0;
for(size_t i = 1; i < w.size(); i++) { for(size_t i = 1; i < w.size(); i++) {
size_t b = res[i]; size_t b = res[i];
......
...@@ -58,8 +58,12 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const string::LinearString < Sym ...@@ -58,8 +58,12 @@ ext::set < unsigned > KnuthMorrisPratt::match ( const string::LinearString < Sym
if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i ); if ( j >= pattern.getContent ( ).size ( ) ) occ.insert ( i );
   
// shift heristics // shift heristics
i += j - ba[j]; if ( j != 0 ) {
j = ba[j]; i += j - ba[j];
j = ba[j];
} else {
i += 1;
}
} }
   
//measurements::end(); //measurements::end();
......
...@@ -26,7 +26,7 @@ static std::string qGenString ( const size_t & len, const size_t &alph_len, cons ...@@ -26,7 +26,7 @@ static std::string qGenString ( const size_t & len, const size_t &alph_len, cons
TEST_CASE ( "ExactMatching", "[integration]" ) { TEST_CASE ( "ExactMatching", "[integration]" ) {
auto definition = GENERATE ( as < std::tuple < std::string, std::string, bool > > ( ), auto definition = GENERATE ( as < std::tuple < std::string, std::string, bool > > ( ),
std::make_tuple ( "Exact Boyer Moore", "stringology::exact::BoyerMoore $subject $pattern", true ), std::make_tuple ( "Exact Boyer Moore", "stringology::exact::BoyerMoore $subject $pattern", true ),
std::make_tuple ( "Exact Knuth Morris Pratt", "stringology::exact::KnuthMorrisPratt $subject $pattern", true ), std::make_tuple ( "Exact Knuth Morris Pratt", "stringology::exact::KnuthMorrisPratt $subject $pattern", false ),
std::make_tuple ( "Exact Boyer Moore Horspool", " stringology::exact::BoyerMooreHorspool $subject $pattern", true ), std::make_tuple ( "Exact Boyer Moore Horspool", " stringology::exact::BoyerMooreHorspool $subject $pattern", true ),
std::make_tuple ( "Exact Reversed Boyer Moore Horspool", " stringology::exact::ReversedBoyerMooreHorspool $subject $pattern", true ), std::make_tuple ( "Exact Reversed Boyer Moore Horspool", " stringology::exact::ReversedBoyerMooreHorspool $subject $pattern", true ),
std::make_tuple ( "Quick Search", "stringology::exact::QuickSearch $subject $pattern", true ), std::make_tuple ( "Quick Search", "stringology::exact::QuickSearch $subject $pattern", true ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment