Using a priority queue in Java
Posted
by Bharat
on Stack Overflow
See other posts from Stack Overflow
or by Bharat
Published on 2010-03-31T18:03:26Z
Indexed on
2010/03/31
18:13 UTC
Read the original article
Hit count: 514
java
|priority-queue
Forgive me if this is a tried question, but I'm having a little difficulty figuring it out.
I currently have a class Node, and each 'node' is a square in a maze. I'm trying to implement the A* algorithm, so each of these nodes will have an f-cost (int) data member inside of it. I was wondering if there's a way that I can create a priority queue of these nodes, and set up the f-cost variable as the comparator?
I've looked at examples online, but all I can find are String priority queues. Can I implement Comparator for the Node class? Would this allow me to access the data member stored inside it?
Many Thanks!
© Stack Overflow or respective owner