-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cc
62 lines (52 loc) · 1.64 KB
/
test.cc
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
#include "updatable_priority_queue.cc"
#include <iostream>
#include <vector>
using namespace std;
typedef pewulfman::updatable_priority_queue<string,int> upq;
int main(){
upq q;
cout << "Test 1" << endl;
q.push({"Thomas",100});
q.push({"Pop",0});
q.push({"Alfred",300});
q.push({"Batman",10000});
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << endl << "Test 2" << endl;
q.push({"Thomas",100});
q.push({"Pop",0});
q.push({"Alfred",300});
q.push({"Batman",10000});
q.update_priority("Pop",50000);
cout << "update Pop to 50000" << endl;
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << endl << "Test 3" << endl;
q.push({"Batman",10000});
q.push({"Alfred",300});
q.push({"Thomas",100});
q.push({"Pop",50000});
q.update_priority("Pop",0);
cout << "update Pop to 0" << endl;
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
cout << q.top().first << ", "<< q.top().second << endl;
q.pop();
return 0;
}