-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (70 loc) · 1.65 KB
/
Copy pathmain.cpp
File metadata and controls
80 lines (70 loc) · 1.65 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "DictionaryTrie.hpp"
#include <string>
#include <iostream>
#include <vector>
int main()
{
DictionaryTrie *mytrie = new DictionaryTrie();
std::string s1("abc ");
std::string s2("ab");
std::string s3("aaa");
bool state1 = mytrie->insert(s1,1);
bool state2 = mytrie->insert(s2,1);
bool state3 = mytrie->insert(s3,1);
if( state1 == false)
{
std::cout<<"s1"<<std::endl;
}
if(state2 == false)
{
std::cout<<"s2"<<std::endl;
}
if( state3 == false)
{
std::cout<<"s3"<<std::endl;
}
bool state4 = mytrie->find(s1);
bool state5 = mytrie->find(s2);
bool state6 = mytrie->find(s3);
if(state4 == false || state5 == false || state6 == false)
{
std::cout<<"2"<<std::endl;
}
bool state7 = mytrie->insert(s1,1);
if(state7 == true)
{
std::cout<<"3"<<std::endl;
}
std::string s4 = "123";
bool state8 = mytrie->find(s4);
if(state8 == true)
{
std::cout<<"4"<<std::endl;
}
std::string s5 = "";
bool state9 = mytrie->insert(s5,1);
if(state9 == true)
{
std::cout<<"5"<<std::endl;
}
std::string s10("1242wasf12g");
bool state10 = mytrie->insert(s10,1);
bool state11 = mytrie->find(s10);
if(state10 == false)
{
std::cout<<"10"<<std::endl;
}
if(state11 == false)
{
std::cout<<"11"<<std::endl;
}
std::string s100 = "a";
std::vector<std::string> myV= mytrie->predictCompletions(s100,10);
while( myV.size() != 0)
{
std::cout<<myV.back()<<std::endl;
myV.pop_back();
}
delete mytrie;
return 0;
}