when we have two values like ID and Marks of a student and we want to put it in a queue we define the priority queue in the following way.
priority_queue<pair<int,int> > queue;
Let us say, that we have four values to put it into a queue. ie., I want all the three values as a single entity in the queue and I will define my own comaprator based on the three values. I'm new to STL and I could not find appropriate way of doing this.
You have std::tuple for such cases. And you write a comparator just like you would write it for a pair.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With