diff --git a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp index a2f6876bf41ee57360f9040b9f2b2678b2e1bec0..eafc56a51fdb2d15ebbe55b893511a8085ca495a 100644 --- a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp +++ b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp @@ -44,25 +44,15 @@ std::set<unsigned> BoyerMooreHorspool::match(const string::LinearString& string, */ 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(); - 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--; - - if(i == 0) // Yay, there is match!!! - { - occ.insert(haystack_offset); - haystack_offset ++; - break; - } } - if(i != 0) - { - haystack_offset += bcs[string.getContent().at(haystack_offset + i - 1)]; - } + // Yay, there is match!!! + if(i == 0) occ.insert(haystack_offset); + haystack_offset += bcs[string.getContent().at(haystack_offset + pattern.getContent().size() - 1)]; //std::cout << haystack_offset << std::endl; } return occ; diff --git a/makefile b/makefile index 89afbc69f21c028a9becac570a24260d21cec8d6..9eb9d672ac467604a079207fdf3c7106fcc2ca33 100644 --- a/makefile +++ b/makefile @@ -75,6 +75,7 @@ debug : all-debug ./tests.adeterminize.sh debug ./tests.aconversion.sh debug ./tests.aderivation.aintegral.sh debug + ./tests.astringology.sh debug release: all-release mkdir -p $(addsuffix -release, $(BINFOLDER)) @@ -89,6 +90,7 @@ release: all-release ./tests.adeterminize.sh release ./tests.aconversion.sh release ./tests.aderivation.aintegral.sh release + ./tests.astringology.sh release clean : clean-debug clean-release $(RM) -r bin-debug bin-release