scire
Sadh's C++ Impromptu Routines Ensemble
|
The Knuth-Morris-Pratt (KMP) algorithm for string-matching problem. More...
#include <knuth_morris_pratt.hpp>
Public Member Functions | |
StringMatchKMP (const CharType *pattern, SzType length) | |
Construct KMP pattern matching object with pattern to find. More... | |
bool | ReadNext (CharType c) |
read next character in text stream More... | |
Static Public Member Functions | |
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. More... | |
The Knuth-Morris-Pratt (KMP) algorithm for string-matching problem.
A KMP object is initialized with a pattern to find. Each character of text is then fed to the object with ReadNext() for matching.
ref:
Definition at line 49 of file knuth_morris_pratt.hpp.
|
inline |
Construct KMP pattern matching object with pattern to find.
pattern | patther to match |
length | lenght of pattern |
Definition at line 131 of file knuth_morris_pratt.hpp.
|
inlinestatic |
Find the position of the first occurrence of a substring in a text.
text | text to search in (haystack) |
textlen | lenth of text |
pattern | pattern to find (substring, needle) |
patternlen | length of pattern |
Definition at line 170 of file knuth_morris_pratt.hpp.
|
inline |
read next character in text stream
c | next char in text stream |
Definition at line 147 of file knuth_morris_pratt.hpp.