Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a priority queue with four values in c++?

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.

like image 616
AV94 Avatar asked Feb 07 '26 18:02

AV94


1 Answers

You have std::tuple for such cases. And you write a comparator just like you would write it for a pair.

like image 94
ixSci Avatar answered Feb 09 '26 10:02

ixSci