Lecture 6 - Slide 11 : 40 |
A priority queue is a heap
top() returns the largest element in the queue
We show an example of a priority queue of points, which is built on top of double-ended queue
A priority queue relies on a comparison function - in our case the overloaded < operator in class Point
A priority queue is an adoptor of an underlying container - defaulted to vector - in the example below we use deque
![]() | Illustration of priority_queue<Point, deque<Point> >. |
![]() | Class point with an overloaded operator<. |
![]() | The implementation of class Point and in particular operator<. |