-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathkmp.h
40 lines (36 loc) · 989 Bytes
/
kmp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file kmp.h
*
* @author hutusi ([email protected])
*
* @brief KMP (Knuth-Morris-Pratt) algorithm.
*
* @date 2019-08-07
*
* @copyright Copyright (c) 2019, hutusi.com
*
*/
#ifndef RETHINK_C_KMP_H
#define RETHINK_C_KMP_H
/**
* @brief KMP algorithm to find the match substring.
*
* @param text The text string.
* @param text_len The length of text.
* @param pattern The pattern string.
* @param pat_len The length of pattern string.
* @return int The first match index, -1 if no match.
*/
int kmp_text_match(const char *text,
unsigned int text_len,
const char *pattern,
unsigned int pat_len);
/**
* @brief KMP algorithm to find the match substring.
*
* @param text The text string.
* @param pattern The pattern string.
* @return int The first match index, -1 if no match.
*/
int kmp_string_match(const char *text, const char *pattern);
#endif /* #ifndef RETHINK_C_KMP_H */