Browse Source

Fin séance 704, tests BH presques OK

Favary Pierre 3 years ago
parent
commit
53eb7eaedf

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

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

Loading…
Cancel
Save