-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.hpp
56 lines (37 loc) · 1.04 KB
/
util.hpp
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
#ifndef UTIL_HPP
#define UTIL_HPP
#include <chrono>
#include "DictionaryTrie.hpp"
#include <iostream>
#include <vector>
using namespace std;
using std::istream;
class Timer{
private:
std::chrono::time_point<std::chrono::high_resolution_clock> start;
public:
/*
* Function called when starting the timer.
*/
void begin_timer();
/*
* Function called when ending the timer. Returns duration in nanoseconds
* PRECONDITION: begin_timer() must be called before this function
*/
long long end_timer();
};
class Utils{
public:
static unsigned int stripFrequency(string& line);
static std::vector<string> getWordsFromLine(string& line);
/*
* Load the words in the file into the dictionary
*/
void static load_dict(DictionaryTrie& dict, istream& words);
/*
* Load num_words from words stream into the dictionary
*/
void static load_dict(DictionaryTrie& dict, istream& words, unsigned int num_words);
void static load_dict(vector<string>& dict, istream& words);
};
#endif //UTIL_HPP