File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ public void insertElement(HeapElement element) {
8484
8585 @ Override
8686 public void deleteElement (int elementIndex ) {
87+ if (isempty (maxHeap )) throw new EmptyHeapException ("Attempt to delete an element from an empty heap" );
8788 if ((elementIndex > maxHeap .size ()) && (elementIndex <= 0 )) throw new IndexOutOfBoundsException ("Index out of heap range" );
8889 // The last element in heap replaces the one to be deleted
8990 maxHeap .set (elementIndex - 1 , getElement (maxHeap .size ()));
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ public void insertElement(HeapElement element) {
8787
8888 @ Override
8989 public void deleteElement (int elementIndex ) {
90+ if (isempty (maxHeap )) throw new EmptyHeapException ("Attempt to delete an element from an empty heap" );
9091 if ((elementIndex > minHeap .size ()) && (elementIndex <= 0 )) throw new IndexOutOfBoundsException ("Index out of heap range" );
9192 // The last element in heap replaces the one to be deleted
9293 minHeap .set (elementIndex - 1 , getElement (minHeap .size ()));
You can’t perform that action at this time.
0 commit comments