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

fix Horspools algorithm enable stringology exact tests

parent cadd5e65
No related branches found
No related tags found
No related merge requests found
...@@ -44,25 +44,15 @@ std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString& string, ...@@ -44,25 +44,15 @@ std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString& string,
*/ */
   
size_t haystack_offset = 0; size_t haystack_offset = 0;
while(haystack_offset + pattern.getContent().size() <= string.getContent().size()) while(haystack_offset + pattern.getContent().size() <= string.getContent().size()) {
{
size_t i = pattern.getContent().size(); size_t i = pattern.getContent().size();
while(string.getContent().at(haystack_offset + i - 1) == pattern.getContent().at(i - 1)) while(i > 0 && string.getContent().at(haystack_offset + i - 1) == pattern.getContent().at(i - 1)) {
{
i--; i--;
if(i == 0) // Yay, there is match!!!
{
occ.insert(haystack_offset);
haystack_offset ++;
break;
}
} }
   
if(i != 0) // Yay, there is match!!!
{ if(i == 0) occ.insert(haystack_offset);
haystack_offset += bcs[string.getContent().at(haystack_offset + i - 1)]; haystack_offset += bcs[string.getContent().at(haystack_offset + pattern.getContent().size() - 1)];
}
//std::cout << haystack_offset << std::endl; //std::cout << haystack_offset << std::endl;
} }
return occ; return occ;
......
...@@ -75,6 +75,7 @@ debug : all-debug ...@@ -75,6 +75,7 @@ debug : all-debug
./tests.adeterminize.sh debug ./tests.adeterminize.sh debug
./tests.aconversion.sh debug ./tests.aconversion.sh debug
./tests.aderivation.aintegral.sh debug ./tests.aderivation.aintegral.sh debug
./tests.astringology.sh debug
   
release: all-release release: all-release
mkdir -p $(addsuffix -release, $(BINFOLDER)) mkdir -p $(addsuffix -release, $(BINFOLDER))
...@@ -89,6 +90,7 @@ release: all-release ...@@ -89,6 +90,7 @@ release: all-release
./tests.adeterminize.sh release ./tests.adeterminize.sh release
./tests.aconversion.sh release ./tests.aconversion.sh release
./tests.aderivation.aintegral.sh release ./tests.aderivation.aintegral.sh release
./tests.astringology.sh release
   
clean : clean-debug clean-release clean : clean-debug clean-release
$(RM) -r bin-debug bin-release $(RM) -r bin-debug bin-release
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment