+ 2

Can't set fulfil purpose of priority queue ?

Hi Please refer below code : My question is on the need of priority queue. Isn't set enough ? It also allows to iterate without removing data from container unlike priority queue. So what's the use case where only priority queue is best compared to set ? https://code.sololearn.com/c0UmZr38D0Qi/?ref=app

11th Dec 2021, 6:12 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 odpowiedzi
+ 1
Well, the first use case that comes to mind is where you need to store duplicate data.. Set won't be enough.. I found this discussion on stackoverflow.. might want to check it out? https://stackoverflow.com/questions/10141841/difference-between-stdset-and-stdpriority-queue
12th Dec 2021, 1:20 AM
Anannya
+ 1
Thanks _______ I checked the link but I still wonder why priority queue is needed I got your point about duplicate data... So multiset will solve the purpose instead of set... But what is need of priority queue
12th Dec 2021, 5:14 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
It's okay and no need to feel sorry or delete the reply... We all are here to learn and appreciate your time and responses. Thank you
12th Dec 2021, 3:22 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
I'm sorry I don't really know much about c++.. After you see this, I'll delete my answers as they didn't help. So that your thread can appear in the "UnAnswered" filter. Hope u can find your answer soon 👍
12th Dec 2021, 3:02 PM
Anannya