Fin séance 704, tests BH presques OK

This commit is contained in:
Favary Pierre 2021-04-07 15:15:42 +02:00
parent aabddfa684
commit 53eb7eaedf

View file

@ -138,10 +138,10 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
@Override
public void remove(E x) throws ElementNotFoundException {
int index=this.array.indexOf(x);
if (index<0)
if (index<0 || this.currentSize<=index)
throw new ElementNotFoundException(x);
this.array.set(index, this.array.get(this.array.size()-1));
this.array.set(index, this.array.get(this.currentSize-1));
this.currentSize--;
this.percolateDown(index);
}