-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutocomplete.h
More file actions
42 lines (37 loc) · 865 Bytes
/
Autocomplete.h
File metadata and controls
42 lines (37 loc) · 865 Bytes
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
40
41
42
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
typedef std::vector<std::string> SuggestVec;
class Autocomplete
{
public:
struct PrefixNode {
std::unordered_map<wchar_t, PrefixNode*> childrens;
bool endOfWord;
PrefixNode()
{
endOfWord = false;
}
~PrefixNode() {
for (auto iter = childrens.begin(); iter != childrens.end(); iter++)
{
delete iter->second;
}
};
};
Autocomplete();
~Autocomplete();
private:
PrefixNode * root;
int k;
//bool is_last_node(PrefixNode * pter);
public:
void instert(const std::string & word);
///? Vector>TO DO ::rETURN
void suggest(const std::string & word);
void change(const int size);
int get_k()const { return k; };
//Change name
void vecAdd( std::string & word, PrefixNode * pNext, SuggestVec & vec,int &count);
};