heap removed impl, tests to fix
This commit is contained in:
parent
cf4f368912
commit
2e20b9b3a6
1 changed files with 10 additions and 0 deletions
|
@ -138,6 +138,16 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
||||||
@Override
|
@Override
|
||||||
public void remove(E x) throws ElementNotFoundException {
|
public void remove(E x) throws ElementNotFoundException {
|
||||||
// TODO:
|
// TODO:
|
||||||
|
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);
|
||||||
|
this.currentSize--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue