@Test public void testOverflow() { LookupPriorityQueue queue = new LookupPriorityQueue(2); queue.insertWithOverflow(new LookupResultItem("1", "test", 1)); queue.insertWithOverflow(new LookupResultItem("2", "test", 2)); queue.insertWithOverflow(new LookupResultItem("3", "test", 3)); assertThat(queue.getResult().stream().map(LookupResultItem::getPhrase).collect(Collectors.toList()), contains("3", "2")); }
List<LookupResultItem> getResult() { int size = this.size(); LookupResultItem[] res = new LookupResultItem[size]; for (int i = size - 1; i >= 0; i--) { res[i] = this.pop(); } return Arrays.asList(res); }
LookupPriorityQueue extends PriorityQueue<LookupResultItem> { List<LookupResultItem> getResult() { int size = this.size(); LookupResultItem[] res = new LookupResultItem[size]; for (int i = size - 1; i >= 0; i--) { res[i] = this.pop(); } return Arrays.asList(res); } }
LookupPriorityQueue extends PriorityQueue<LookupResultItem> { List<LookupResultItem> getResult() { int size = this.size(); LookupResultItem[] res = new LookupResultItem[size]; for (int i = size - 1; i >= 0; i--) { res[i] = this.pop(); } return Arrays.asList(res); } LookupPriorityQueue(final int maxSize); }
LookupPriorityQueue extends PriorityQueue<LookupResultItem> { List<LookupResultItem> getResult() { int size = this.size(); LookupResultItem[] res = new LookupResultItem[size]; for (int i = size - 1; i >= 0; i--) { res[i] = this.pop(); } return Arrays.asList(res); } LookupPriorityQueue(final int maxSize);  }
LookupPriorityQueue extends PriorityQueue<LookupResultItem> { List<LookupResultItem> getResult() { int size = this.size(); LookupResultItem[] res = new LookupResultItem[size]; for (int i = size - 1; i >= 0; i--) { res[i] = this.pop(); } return Arrays.asList(res); } LookupPriorityQueue(final int maxSize);   }