SimpleHeapImpl implements Heap<T> { @Override public T pop() throws EmptyHeapException { if (heap.isEmpty()) { throw new EmptyHeapException(); } com.github.kowshik.bigo.common.ListUtils.swap(heap, 0, heap.size() - 1); T toReturn = heap.remove(heap.size() - 1); heapify(0); return toReturn; } SimpleHeapImpl(Comparator<T> comparator);  SimpleHeapImpl(List<T> list, Comparator<T> comparator);  SimpleHeapImpl(T[] array, Comparator<T> comparator); @Override int size(); @Override T peek(); @Override T pop(); @Override void add(T element); @Override boolean isEmpty();  }
@Test public void popThrowsExceptionWhenHeapIsEmpty() { Heap<Integer> heap = new SimpleHeapImpl<Integer>(minHeapComparator); boolean thrown = false; try { heap.pop(); } catch (EmptyHeapException e) { thrown = true; } assertTrue(thrown); }