⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kmpsearch.h

📁 一个我的数据结构解题集合
💻 H
字号:
#ifndef KMPSEARCH_H__
#define KMPSEARCH_H__

#include <string>
#include "Vector.h"
using namespace std;


/* 利用KMP算法在主串str中从pos开始搜索模式ptn,
 * 若找到返回第一次出现的位置, 否则返回str.size()
 */
int KmpSearch(const string& str, const string& ptn, int pos = 0);

/* 利用KMP算法在主串str中搜索所有模式ptn, (允许重叠)
 * 返回找到的下标的数组
 */
Vector<int> KmpSearchAll(const string& str, const string& ptn);

/* 利用KMP算法在主串str中搜索所有模式ptn, (不允许重叠)
 * 返回找到的下标的数组
 */
Vector<int> KmpSearchAllNoOverlap(const string& str, const string& ptn);

#endif // KMPSEARCH_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -