forked from akibzaman/Beginners-Data-Structure
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvectorPQSTL.cpp
49 lines (37 loc) · 955 Bytes
/
vectorPQSTL.cpp
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
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PAIR;
int main(){
vector<int> V (3,-1);
for(int i = 0;i <V.size();i++){
cout << V[i] << " ";
}
cout << endl << endl;
V.push_back(4);
//iterator
vector<int> :: iterator it;
for(it=V.begin();it!=V.end();it++){
cout << *it << " ";
}
cout << endl << endl;
//'auto' Register in range based traversal
for(auto element: V){
cout<< element << " ";
}
cout << endl << endl;
// auto register in place of iterator
for(auto it=V.begin();it!=V.end();it++){
cout << *it << " ";
}
cout << endl << endl;
priority_queue<PAIR, vector<PAIR>> PQ;
PQ.push(make_pair(1,9));
PQ.push(make_pair(6,2));
PQ.push(make_pair(4,1));
while(!PQ.empty()){
cout << PQ.top().first << "|" << PQ.top().second << endl;
PQ.pop();
}
cout << endl << endl;
return 0;
}