Both are container adaptors and both are defined in the header <queue>
still they both have different interfaces to access the 'first' element. I can understand the lack of a back
due to the constraints of the data structure but naming front
differently confuses me.
The priority_queue
container adaptor is a convenience wrapper for the standard library's heap algorithms, using a sequence container as a classic binary heap. The name top
likely reflects this association; we speak of the "top" of a heap, since we visualize it as a heap-ordered binary tree, with the element of greatest priority at the root (top).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With