Edge cases to fix

This commit is contained in:
Clement Lacau 2024-04-05 00:55:52 +02:00
parent 2e20b9b3a6
commit c68a969b91

View file

@ -141,13 +141,13 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
if (isEmpty() || !array.contains(x)) {
throw new ElementNotFoundException(x);
}
int pere = 1;
int indice_suppression = array.indexOf(x);
array.remove(indice_suppression);
arraySet(indice_suppression, array.get(this.currentSize));
array.remove(this.currentSize);
percolateUp(indice_suppression);
arraySet(indice_suppression, array.get(this.currentSize - 1));
//array.remove(this.currentSize);
this.currentSize--;
if (indice_suppression < this.currentSize) {
percolateDown(indice_suppression);
}
}
@Override