Fin séance 704, tests BH presques OK
This commit is contained in:
parent
aabddfa684
commit
53eb7eaedf
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue