-
priority queue
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:
Code:
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
-
Re: priority queue
C++ already has a priority_queue class as part of the standard library.
Code:
template <class T, class Container = vector<T>,
class Compare = less<typename Container::value_type> >
class priority_queue;