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
1 Antwort
+ 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.