19 #ifndef SCIRE_string_knuth_morris_pratt_HPP
20 #define SCIRE_string_knuth_morris_pratt_HPP
48 template<
typename CharType =
char,
typename SzType =
size_t>
52 const CharType* pattern;
61 static const CharType*
67 if (
str == 0)
return 0;
89 BuildFailureFunctions(
90 const CharType* pattern,
94 if (
pattern ==
nullptr)
return nullptr;
95 if (
len == 0)
return nullptr;
97 if (
F ==
nullptr)
return nullptr;
132 const CharType* pattern,
151 if (
F == 0)
return false;
154 if (
index == 0)
return false;
171 const CharType* text,
173 const CharType* pattern,
The Knuth-Morris-Pratt (KMP) algorithm for string-matching problem.
scire/graph/gale_shapley.hpp
bool ReadNext(CharType c)
read next character in text stream
StringMatchKMP(const CharType *pattern, SzType length)
Construct KMP pattern matching object with pattern to find.
static SzType Position(const CharType *text, SzType textlen, const CharType *pattern, SzType patternlen)
Find the position of the first occurrence of a substring in a text.