-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionaryWords.cpp
More file actions
43 lines (34 loc) · 795 Bytes
/
DictionaryWords.cpp
File metadata and controls
43 lines (34 loc) · 795 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
43
#include "DictionaryWords.h"
#include "Trie_Node.h"
#include <fstream>
extern int (*gPrintFn)( const char * format, ... );
DictionaryWords::DictionaryWords(const char* fileName)
{
mp_Dictionary = new Trie_Node('\0');
// Populate Dictionary with words from fileName
std::string line;
std::ifstream myfile (fileName);
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
//gPrintFn(" %s \n", line.c_str());
mp_Dictionary->Insert(line);
}
myfile.close();
}
else // TODO: throw exception
{
gPrintFn("Unable to open file\n");
}
}
DictionaryWords::~DictionaryWords(void)
{
delete mp_Dictionary;
mp_Dictionary = 0;
}
bool DictionaryWords::Search(const std::string &ar_Word, bool pattern)
{
return mp_Dictionary->Search(ar_Word, pattern);
}