I have a comparator class NComparator that compares 2 Node objects and returns either 1, -1, or 0.
I initialized a PriorityQueue with an initial capacity of 100 and that NComparator.
NComparator nc = new NComparator();
PriorityQueue<Node> pq = new PriorityQueue<Node>(100, nc);
I have about 25 Node objects (that can be compared with NComparator), and I added them all to the PriorityQueue Object:
pq.add(new Node("A", 3));
pq.add(new Node("G", 1));
pq.add(new Node("B", 10));
.... etc
How can I arrange these node objects in PriorityQueue by the priority returned by the comparator (which only compares pairwise combinations of nodes)? Specifically, I would like to be able to access the two nodes with the least priority in this PriorityQueue. How can I do that?