Priority Queue
1. empty
2. size
3. top
4. push
5. pop
6. swap
mypqueue1.swap(mypqueue2);
7. For Min Heap
priority_queue <int, vector<int>, greater<int> > pq;
8. For Pairs(Ordered by First)
priority_queue<pair<int, int> > pq;
pq.push(make_pair(10, 200));
String
1. string str;
2. getline(cin,str);
3. int pos = str.find(".");
if (pos == string::npos)
return "";
4. reverse(str.begin(), str.end());
Queue
1.empty
2.size
3.swap
queue1.swap(queue2);
4.front
5.back
6.push
7.pop
Pair
1. pair <int, char> PAIR1 ;
PAIR1.first = 100;
PAIR1.second = 'G' ;
cout << PAIR1.first << " " ;
cout << PAIR1.second << endl ;
2. pair <string, double> PAIR3 ;
PAIR3 = make_pair ("GeeksForGeeks is Best",4.56);
Unordered_Map
1.unordered_map<string, int> umap;
2. if (umap.find(key) == umap.end())
cout << key << " not found\n\n";
Lower_bound and Upper_bound
sort(vect.begin(), vect.end());
// Returns the first occurrence of 20
auto q = lower_bound(vect.begin(), vect.end(), 20);
// Returns the last occurrence of 20
auto p = upper_bound(vect.begin(), vect.end(), 20);
cout << "The lower bound is at position: ";
cout << q-vect.begin() << endl;
cout << "The upper bound is at position: ";
cout << p-vect.begin() << endl;
Vector
1.push_back
2.erase(int position): Removes the element present at position. Ex:
v.erase(v.begin()+4); (erases the fifth element of the vector v)
3.erase(int start,int end): Removes the elements in the range from start to
end inclusive of the start and exclusive of the end
v.erase(v.begin()+2,v.begin()+5)
4. iterator1= vec1.begin();
vec1.insert ( iterator1+i , vec2[i] );
// This means that at position "i" from the beginning it will insert the value from vec2 from position i