RubbishBin/zip-unzip-search/include/search.h

56 lines
1.0 KiB
C
Raw Normal View History

2024-10-30 17:23:52 +08:00
//
// Created by ricardo on 22-12-16.
//
#ifndef ZIP_UNZIP_SEARCH_SEARCH_H
#define ZIP_UNZIP_SEARCH_SEARCH_H
#include "vector"
#include "array"
#include "string"
/**
* BM算法搜索实现类
*/
class BMSearch
{
public:
explicit BMSearch(std::vector<char>& sample);
~BMSearch();
/**
*
* @param fileName
*/
void matchFile(std::string &fileName);
private:
// 坏字符规则数组
// 字符串为01串
int* badCharArray;
// 好后缀规则数组
int* goodSuffixArray;
std::vector<char>* sample;
/**
*
* @param s
*/
void generateBrokenCharArray(std::vector<char>& s);
/**
*
* @param s
*/
void generateGoodSuffixArray(std::vector<char>& s);
static int max(int a, int b);
};
void SearchInFile(char* fileName, char* sample);
#endif //ZIP_UNZIP_SEARCH_SEARCH_H