From 8ce411fcd28c754522d022244f0c234447878e4b Mon Sep 17 00:00:00 2001 From: Pellerin Tiphaine Date: Thu, 16 Apr 2026 09:10:36 +0200 Subject: [PATCH] tas binaire remove --- .../insa/graphs/algorithm/utils/BinaryHeap.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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