-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
86 lines (72 loc) · 2.39 KB
/
main.cpp
File metadata and controls
86 lines (72 loc) · 2.39 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <string>
#include <fstream>
#include "ClassLinkedList.h"
#include "ClassLinkedListNode.h"
#include "ClassRecord.h"
#include "Auxiliary.h"
#include "ClassAVLTreeNode.h"
#include "ClassAVLTree.h"
#include "ClassHashTable.h"
#include "ClassHeapTree.h"
#include "ClassHeapTreeNode.h"
using namespace std;
int main(int argc, char **argv){
string* patientRecordsFile;
string* dhtNumOfEntriesStr;
string* chtNumOfEntriesStr;
string* bucketSizeStr;
int diseaseHashtableNumOfEntries;
int countryHashtableNumOfEntries;
int bucketSize;
//Getting the values of given arguments
patientRecordsFile = getArgument("-p", argc, argv);
dhtNumOfEntriesStr = getArgument("-h1", argc, argv);
chtNumOfEntriesStr = getArgument("-h2", argc, argv);
bucketSizeStr = getArgument("-b", argc, argv);
diseaseHashtableNumOfEntries = stoi(*dhtNumOfEntriesStr);
countryHashtableNumOfEntries = stoi(*chtNumOfEntriesStr);
bucketSize = stoi(*bucketSizeStr);
LinkedList list;
AVLTree tree;
ifstream infile;
HashTable hashTable1(countryHashtableNumOfEntries);
HashTable hashTable2(diseaseHashtableNumOfEntries);
HeapTree heap;
//Reading the given file line by line
infile.open(*patientRecordsFile);
string line;
Record* recordPtr;
string* countryStr;
string* diseaseStr;
if (infile.is_open()) {
while (getline(infile, line)) {
recordPtr = new Record(line);
//printf("%s\n", line.c_str());
if(!(list.contains(recordPtr->getRecordId()))){
// list.insertItem(recordPtr);
// tree.insertItem(recordPtr);
countryStr = new string(recordPtr->getCountry());
diseaseStr = new string(recordPtr->getDisease());
hashTable1.insertItem(countryStr, bucketSize, recordPtr);
hashTable2.insertItem(diseaseStr, bucketSize, recordPtr);
heap.insertItem(recordPtr);
}
}
}
//list.printList();
//tree.printTree();
hashTable1.displayHash();
hashTable2.displayHash();
cout << "SHOWING HEAP" << endl;
heap.showHeap();
heap.deleteRoot();
cout << "SHOWING HEAP" << endl;
heap.showHeap();
// heap.deleteRoot();
// heap.showHeap();
// heap.deleteRoot();
// heap.showHeap();
// heap.deleteRoot();
// heap.showHeap();
}