u1Node is some simple container class:
node1 = new u1Node();
node2 = new u1Node();
node3 = new u1Node();
node4 = new u1Node();
PriorityQueue<u1Node> minHeap=new PriorityQueue<u1Node>();
Now i'd like to do this:
minHeap.add(node2,43);
minHeap.add(node1,22);
minHeap.add(node4,153);
minHeap.add(node3,2);
In order to do this:
mostImportantObject = new u1Node();
mostImportantObject = minHeap.poll();
And get mostImportantObject=node3, since the "key" to node3 is 2, and it is the lowest key by which the minheap is sorted. It is not permitted to write in this way in java, so how should i do it?