Queue in STL are a type of container adaptors which operate in a first in first out (FIFO) type of arrangement where elements are inserted at the back (end) and are deleted from the front. Queue of pair can be very efficient in designing complex data structures. The first element is referenced as ‘first’ and the second element as ‘second’ and the order is fixed (first, second).
Queue<pair<datatype, datatype>> queue_of_pair;
Below is an example to show the Queue of Pairs:
Queue of Pairs: (10, 20) (15, 5) (1, 5) (5, 10) (7, 9) Size of Queue of Pairs: 5 Front of Queue of Pairs: (10, 20) Back of Queue of Pairs: (7, 9) Removing the Front pair Current Queue of Pairs: (15, 5) (1, 5) (5, 10) (7, 9)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- queue::empty() and queue::size() in C++ STL
- queue::push() and queue::pop() in C++ STL
- queue::front() and queue::back() in C++ STL
- Priority Queue of Vectors in C++ STL with Examples
- Stack and Queue in Python using queue Module
- Check if a queue can be sorted into another queue using a stack
- Reversing a Queue using another Queue
- Difference between Circular Queue and Priority Queue
- Queue in Standard Template Library (STL)
- Priority Queue in C++ Standard Template Library (STL)
- queue::swap() in C++ STL
- queue::emplace() in C++ STL
- STL Priority Queue for Structure or Class
- Does STL priority queue allow duplicate values?
- Find the Deepest Node in a Binary Tree Using Queue STL - SET 2
- Priority queue of pairs in C++ (Ordered by first)
- Priority queue of pairs in C++ with ordering by first and second element
- Map of pairs in STL
- multiset lower_bound() in C++ STL with Examples
- multiset upper_bound() in C++ STL with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.