-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cc
More file actions
53 lines (45 loc) · 1.16 KB
/
Copy pathtest.cc
File metadata and controls
53 lines (45 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
#include <iostream>
#include <cstring>
#include <stdlib.h> /* srand, rand */
#include <time.h>
#include "FibHeap.h"
#include "CompositeKey.h"
#include "Record.h"
#include "DBFile.h"
using namespace std;
int main (int argc, char* argv[]) {
cout<<"Hello World?"<<endl;
FibHeap fh;
srand (time(NULL));
int num = 1000;
for(int i = 0; i < num; i++) {
CompositeKey key;
int randInt = rand()%10 + 1; // changed divisor to see more duplicates
key.addInt(randInt);
double randDbl = (rand()%100 + 1)/10.0;
key.addDbl(randDbl);
string randStr = to_string(rand()%num + 1);
char* randStrC = new char[randStr.length()+1];
strcpy(randStrC, randStr.c_str());
key.addStr(randStrC);
// Record rec; DBFile* dbf;
fh.insert(key);//, rec, dbf);
}
CompositeKey prev;
fh.extractmin(prev);//, rec, dbf);
cout<<"Numbers inserted in Fibonacci Heap -"<<endl;
cout << prev << endl;
for(int i = 1; i < num; i++) {
CompositeKey key;
fh.extractmin(key);//, rec, dbf);
cout << key << endl;
if (key < prev) {
cout<< "Wrong Result!!!!"<<endl;
break;
}
else {
prev = key;
}
}
return 0;
}