aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/deprecated/kmp/kmp.cpp
blob: d9bb37fb5b1e43949913fcd20bc9aecf9e99dc41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "kmp.h"

#include <util/generic/yexception.h>
 
TKMPMatcher::TKMPMatcher(const char* patternBegin, const char* patternEnd) 
    : Pattern(patternBegin, patternEnd) 
{ 
    ComputePrefixFunction(); 
} 
 
TKMPMatcher::TKMPMatcher(const TString& pattern)
    : Pattern(pattern) 
{ 
    ComputePrefixFunction(); 
} 
 
void TKMPMatcher::ComputePrefixFunction() { 
    ssize_t* pf; 
    ::ComputePrefixFunction(Pattern.data(), Pattern.data() + Pattern.size(), &pf);
    PrefixFunction.Reset(pf); 
}