-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrie.h
39 lines (36 loc) · 1.1 KB
/
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
39
#pragma once
#include "PoolAllocator.h"
#include "HashMap.h"
#include <string>
namespace jumbuna {
struct TrieNode {
Map<char, TrieNode*> map;
bool EOW = false; //end of word
};
class Trie {
void insert(std::string &, size_t, TrieNode *);
void removeByWord(std::string &, size_t, TrieNode *);
void removeByPrefix(std::string&, size_t, TrieNode *);
bool fullStringSearch(std::string&, size_t, TrieNode *);
bool prefixStringSearch(std::string&, size_t, TrieNode *);
void recursiveNodeDelete(TrieNode *);
void findPrefixEndPoint(std::string &, size_t, TrieNode *, Vector<std::string> &);
void constructWord(std::string &, Vector<std::string> &, TrieNode *);
TrieNode *root;
size_t stringCount;
Allocator<TrieNode> nodeAllocator;
public:
Trie();
void insert(std::string);
void removeWord(std::string);
void removePrefix(std::string);
bool containsFullString(std::string);
bool containsStringPrefix(std::string);
Vector<std::string> wordsWithPrefix(std::string);
//lack of a better functionName :)
Vector<std::string> correctiveText(std::string&);
size_t size();
void clear();
};
}
#include "TrieImpl.h"