@Test
public void testOrder() {
Queue<CountKey<KeyObject>> queue = new PriorityQueue<CountKey<KeyObject>>(10);
List<CountKey<KeyObject>> keys = new ArrayList<CountKey<KeyObject>>();
for (int i = 0; i < 10; i++) {
CountKey<KeyObject> k = new CountKey<KeyObject>(new KeyObject(i + ""));
if (i == 7) {
k.incrementCount();
k.incrementCount();
k.incrementCount();
}
keys.add(k);
queue.offer(k);
}
// for (int i = 0; i < 10; i++) {
// System.out.println(queue.peek());
// }
keys.get(5).incrementCount();
keys.get(6).incrementCount();
keys.get(5).incrementCount();
queue = new PriorityQueue<>(keys);
queue.poll();
queue.offer(new CountKey<>(new KeyObject(87 + "")));
for (int i = 0; i < 10; i++) {
System.out.println(queue.poll());
}
}