diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java index a5073cd..b5c8401 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java @@ -135,6 +135,22 @@ public class BinaryHeap> implements PriorityQueue { @Override public void remove(E x) throws ElementNotFoundException { // TODO: + if (this.isEmpty()) { + throw new ElementNotFoundException(x); + } + int i = this.array.indexOf(x); + if (i == -1) { + throw new ElementNotFoundException(x); + } + if (i > this.size() - 1) { + throw new ElementNotFoundException(x); + } + else { + this.arraySet(i, this.array.get(this.size() - 1)); + this.percolateUp(i); + this.percolateDown(i); + this.currentSize -= 1; + } } @Override