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)) {
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue