-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrie.h
38 lines (35 loc) · 878 Bytes
/
Trie.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
//
// Trie.hpp
// Trie
//
// Created by 佘国榛 on 2017/6/30.
// Copyright © 2017年 佘国榛. All rights reserved.
//
#ifndef Trie_hpp
#define Trie_hpp
#include <iostream>
#include "TrieNode.h"
class Trie{
private:
std::string helper;
TrieNode* root;
bool finished_init;
private:
void DeconstructRec(TrieNode* root);
bool DeleteWordRec(std::string& word, TrieNode* root, int index);
int InitializeFailPointer();
int InitializeNode();
void InsertWord(std::string& word);
bool DeleteFailPointerRec(TrieNode* root);
bool ReconstructFailPointer();
void AcMatchFile(std::string& str);
public:
Trie();
bool FindWord(std::string& word);
bool DeleteWord(std::string& word);
int NaiveMatchString(std::string& str);
int AcMatchString(std::string& str);
void Interact();
~Trie();
};
#endif /* Trie_hpp */