Hi all,
I want to know how can i use priority_queue STL when the top element will be the maximum value. Default constructor are increasing order, thats why when i modified them then i got compile error. Please help me. Thanks in advance.
Problem About Priority Queue STL !!!!
Moderator: Board moderators
Code: Select all
priority_queue<myClass, vector<myClass>, greater<myClass> > myQueue
-
- Guru
- Posts: 584
- Joined: Thu Jun 19, 2003 3:48 am
- Location: Sanok, Poland
- Contact:
(Sigh.)Chok wrote:Hi misof,
Thankx for ur reply. But one question again, what is the type of myClass ? vector<int>myClass ??
myClass is an arbitrary class such that the instances can be compared using the < operator. Any of the default types will work.
Code: Select all
priority_queue<int, vector<int>, greater<int> > Q;
Q.push(6);
Q.push(2);
Q.push(145);
cout << Q.top() << endl;