Browse Source

Mi-séance 704, problèmes tests BH

Favary Pierre 3 years ago
parent
commit
aabddfa684

+ 7
- 1
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java View File

@@ -137,7 +137,13 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
137 137
 
138 138
     @Override
139 139
     public void remove(E x) throws ElementNotFoundException {
140
-        // TODO:
140
+    	int index=this.array.indexOf(x);
141
+    	if (index<0)
142
+    		throw new ElementNotFoundException(x);
143
+    	
144
+    	this.array.set(index, this.array.get(this.array.size()-1)); 
145
+    	this.currentSize--;
146
+    	this.percolateDown(index);
141 147
     }
142 148
 
143 149
     @Override

Loading…
Cancel
Save