-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (46 loc) · 1.16 KB
/
main.cpp
File metadata and controls
58 lines (46 loc) · 1.16 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
//
// main.cpp
// BKTree
//
// Created by Kyle Bludworth on 12/7/15.
// Copyright © 2015 Kyle Bludworth. All rights reserved.
//
#include <iostream>
#include <fstream>
#include <time.h>
#include "BKTree.h"
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::ifstream;
int main(int argc, const char * argv[]) {
BKTree* tree = new BKTree();
string line;
ifstream myFile("words.txt"); // 154,937 English words
clock_t start;
clock_t end;
double elapsed_secs;
if (myFile.is_open())
{
cout << "Building structure... " << endl;
while (getline(myFile, line))
tree->add(line);
myFile.close();
}
cout << "Done." << endl << endl;
string word;
while (word != "quit")
{
cout << "Enter word: ";
cin >> word;
tree->cleanString(word);
start = clock();
tree->search(word, 1);
end = clock();
elapsed_secs = double(end - start) / CLOCKS_PER_SEC;
cout << "Results found in "<< elapsed_secs << "s" << endl << endl;
}
return 0;
}