Arch1tect
Arch1tect

Reputation: 4281

Why priority_queue doesn't have front() but top()

Since it's a 'queue', shouldn't the method be called front() rather than top() ? Is there some reason behind this?

Upvotes: 1

Views: 122

Answers (1)

xaxxon
xaxxon

Reputation: 19761

It's because (in my estimation - as I didn't name it..) they're commonly implemented with heaps which conceptually have a top - as in stuff rises to the top of the heap to be taken off next.

https://en.wikipedia.org/wiki/Priority_queue

Upvotes: 2

Related Questions