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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.