Edge cases to fix
This commit is contained in:
parent
2e20b9b3a6
commit
c68a969b91
1 changed files with 5 additions and 5 deletions
|
@ -141,13 +141,13 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
||||||
if (isEmpty() || !array.contains(x)) {
|
if (isEmpty() || !array.contains(x)) {
|
||||||
throw new ElementNotFoundException(x);
|
throw new ElementNotFoundException(x);
|
||||||
}
|
}
|
||||||
int pere = 1;
|
|
||||||
int indice_suppression = array.indexOf(x);
|
int indice_suppression = array.indexOf(x);
|
||||||
array.remove(indice_suppression);
|
arraySet(indice_suppression, array.get(this.currentSize - 1));
|
||||||
arraySet(indice_suppression, array.get(this.currentSize));
|
//array.remove(this.currentSize);
|
||||||
array.remove(this.currentSize);
|
|
||||||
percolateUp(indice_suppression);
|
|
||||||
this.currentSize--;
|
this.currentSize--;
|
||||||
|
if (indice_suppression < this.currentSize) {
|
||||||
|
percolateDown(indice_suppression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue