-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.h
41 lines (30 loc) · 1022 Bytes
/
testing.h
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
#ifndef TESTING_H
#define TESTING_H
#include <QFile>
#include <QTextStream>
#include <QIODevice>
#include <QStringList>
#include <QDebug>
#include <typeinfo>
#include <QCharRef>
#include <QHash>
#include <QByteArray>
#include <QDataStream>
class Testing
{
public:
Testing();
void experimentOnByteArray();
void readFile(const QString& filePath);
void buildPrefixTree(const QStringList& words);
bool search(const QString& word);
int getLetterIndex(const QChar& letter);
// PrefixTreeNode returnPointer(PrefixTreeNode* node);
private:
QHash<QChar, int> charCounts; //contains the number of time each character occurs
void countCharsInString(const QString& s); //appends key/values to charCounts
int totalCharacterCount;
QHash<QChar, double> charFrequencies; //contains the probability/frequency of each character appearing.
void createCharFrequency(); //uses values in charCounts to populate charFrequencies with probability of each character
};
#endif // TESTING_H