Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lab6 / Aho-Corasick

.h
Скачиваний:
5
Добавлен:
05.02.2020
Размер:
679 б
Скачать
#pragma once

#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;
using lli = long long int;

struct Node {
	string pattern;
	pair<char, Node*> inEdge;
	map<char, Node*> outEdges;
	Node *failure, *output;

	Node(pair<char, Node*> inEdge): inEdge(inEdge), failure(nullptr), output(nullptr) {}
};

struct Trie {
	Node* root;

	Trie(set<string> patterns);

private:
	void makeLinks(Node* &node);
};


map<string, set<lli>> AhoCorasick(string &text, Trie &trie);
set<lli> AhoCorasickWithJoker(string &text, string &myTemplate, char joker);
set<string> split(string &myTemplate, char delim);
Соседние файлы в папке lab6