0

Can't we have set as data structure for priority queue?

Hi I belive vector is default data structure for priority queue. Hence pq1 and pq2 is working in below code: Do I miss something to use set as data structure for priority queue or is it not at all allowed? Why pq3 does not build ? https://code.sololearn.com/c1zKZ8A9WrEh/?ref=app

4th Mar 2022, 6:16 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Odpowiedź
+ 2
According to the documentation for priority_queue https://en.cppreference.com/w/cpp/container/priority_queue. The container needs to provide: front() push_back() pop_back() None of these are provided by set. You could technically extend a custom set to include those functions. But that would be rather pointless.
4th Mar 2022, 11:20 PM
Mustafa A
Mustafa A - avatar