I try to write a program using a priorityQueue ADT ( the documentation is found here: http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html ). The priorityQueue orders instances of a nested class Node which has two variables: an integer representing the weight (or the priority) and a String representing the information to be stored inside the queue.
The problem I face is to change an element's priority (i.e. its weight) without pulling the element out of the queue ( using the function remove() ) and then pushing a new one with the new priority ( using the function add() ). I would like to be able to change the integer representing the weight inside an instance of a class Node inside the queue and then the priorityQueue will reorder itself to find if there is a new Node to place at the head of the queue.
And a last thing: I don't have to use the priorityQueue ADT. If there is any other ADT that resolves this issue in a more elegant manner, be free to mention it!
I am pretty sure I'm not the first person to encounter this difficulty so I'm sorry if there is already an answer to this question anywhere on this website but I haven't found it.