TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Horspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm) More...
#include <iostream>
#include <unordered_map>
#include <cassert>
Go to the source code of this file.
Namespaces | |
namespace | strings |
String algorithms. | |
namespace | horspool |
Functions for Horspool's algorithm. | |
Functions | |
std::unordered_map< char, int > | strings::horspool::findShiftTable (const std::string &prototype) |
bool | strings::horspool::horspool (const std::string &text, const std::string &prototype) |
static void | test () |
Function with test cases for Horspool's algorithm. | |
int | main () |
Main Function that calls test function. | |
Horspool's algorithm that finds if a string contains a substring (https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm)
Definition in file horspool.cpp.
std::unordered_map< char, int > strings::horspool::findShiftTable | ( | const std::string & | prototype | ) |
A function that finds the shift table of the given prototype string that we need in Horpool's algorithm.
prototype | is the substring that we use to find shift table |
Definition at line 26 of file horspool.cpp.
bool strings::horspool::horspool | ( | const std::string & | text, |
const std::string & | prototype ) |
A function that implements Horspool's algorithm.
text | is the string that we are searching if there is a substring |
prototype | is the substring that we are searching in text |
Definition at line 59 of file horspool.cpp.
int main | ( | void | ) |
Main Function that calls test function.
Definition at line 119 of file horspool.cpp.
|
static |
Function with test cases for Horspool's algorithm.
Definition at line 100 of file horspool.cpp.