Lecture overview -- Keyboard shortcut: 'u'  Previous page: Overview of containers -- Keyboard shortcut: 'p'  Next page: A map example -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 25 : 39
Notes about C++
Templates and The Standard Library
A priority queue example

A priority queue is a heap

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 adapts an underlying container, defaulted to vector - we try a deque instead.

  • The C++ Programming Language: Page 478
 

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/containers/priority-queue/point.hClass point with an overloaded operator<.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/containers/priority-queue/point.ccThe implementation of class Point and in particular operator<.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/containers/priority-queue/pri-queue-1.cppIllustration of priority_queue<Point, deque<Point> >.