Compare commits
2 commits
cf4f368912
...
c68a969b91
| Author | SHA1 | Date | |
|---|---|---|---|
| c68a969b91 | |||
| 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
|
||||
public void remove(E x) throws ElementNotFoundException {
|
||||
// TODO:
|
||||
if (isEmpty() || !array.contains(x)) {
|
||||
throw new ElementNotFoundException(x);
|
||||
}
|
||||
int indice_suppression = array.indexOf(x);
|
||||
arraySet(indice_suppression, array.get(this.currentSize - 1));
|
||||
//array.remove(this.currentSize);
|
||||
this.currentSize--;
|
||||
if (indice_suppression < this.currentSize) {
|
||||
percolateDown(indice_suppression);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue