java.util.PriorityQueue...
Moderator: Board moderators
java.util.PriorityQueue...
I want a working code snippet with priority queue of java which takes a double array ... I am interested in insert and retrieval oprerations... I need to know how this class works... and I am not a Java guy. Thanks in advance.
regards,
nymo
nymo
Re: java.util.PriorityQueue...
I don't understand the part of the "double array", but here's a Dijkstra implementation in Java which uses a PriorityQueue. This should work as a template. Basically what you have to do is create a class that implements interface Comparable (you should create a method called compareTo) and then create a new PriorityQueue<MyClass>. Be careful, it's a little different to C++ STL priority_queue, in the sense that in C++ the biggest element is on top of the queue, but on Java's PriorityQueue, it's the smallest element the one on top.
Here's the link: http://www.cs.purdue.edu/homes/czajkat/progchal/
Look at problem C from match 4 (Oct. 7, 2006), and look for the sample C.java solution in the zipfile.
Here's the link: http://www.cs.purdue.edu/homes/czajkat/progchal/
Look at problem C from match 4 (Oct. 7, 2006), and look for the sample C.java solution in the zipfile.
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.
Are you dreaming right now?
http://www.dreamviews.com
Are you dreaming right now?
http://www.dreamviews.com