Click to See Complete Forum and Search --> : priority queue


Denion
December 8th, 2004, 05:57 AM
Hi I'm working on a graph assignment for school. I need to implement a priority queue or minheap. I am fairly new to c++. How do you implement a priority que using an abstract data type. For instance I would like to be able to to have an edge * e and a queue q so that I could enque e using its cost value.

Sorry if that didn't make alot of sense:

This won't complie but heres what I'm trying to do:

edge * e = new edge(string routerOne, string routerTwo, int cost);

priority_queue<* edge>*q;

q.enque(e);




I would like to do this so that edge is cost is used to determine priority

Graham
December 8th, 2004, 06:28 AM
C++ already has a priority_queue class as part of the standard library.

template <class T, class Container = vector<T>,
class Compare = less<typename Container::value_type> >
class priority_queue;