-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrie_test.cc
37 lines (30 loc) · 1001 Bytes
/
trie_test.cc
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
#include <iostream>
#include <string>
#include "trie.h"
using namespace std;
int main() {
trie words;
words.insert("table");
words.insert("tar");
words.insert("tart");
words.insert("trie");
words.insert("trip");
words.insert("try");
// words.insert("tare");
words.insert("tab");
words.insert("milkman");
words.insert("milkyway");
words.insert("milady");
words.print( cout );
cout << endl;
string milkyway = words.compress("milkyway");
cout << "milkyway => " << milkyway << " => " << words.expand( milkyway ) << endl;
string milkman = words.compress("milkman");
cout << "milkman => " << milkman << " => " << words.expand( milkman ) << endl;
string milady = words.compress("milady");
cout << "milady => " << milady << " => " << words.expand( milady ) << endl;
string tar = words.compress("tar");
cout << "tar => " << tar << " => " << words.expand( tar ) << endl;
string tart = words.compress("tart");
cout << "tart => " << tart << " => " << words.expand( tart ) << endl;
}