Merge branch 'master' of https://git.etud.insa-toulouse.fr/brunetto/BEGraphes
This commit is contained in:
commit
25bb414920
1 changed files with 29 additions and 2 deletions
|
@ -137,8 +137,35 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(E x) throws ElementNotFoundException {
|
public void remove(E x) throws ElementNotFoundException {
|
||||||
// TODO:
|
int i;
|
||||||
|
E lastE;
|
||||||
|
boolean notFound = true;
|
||||||
|
for(i = 0; i< this.currentSize; i++)
|
||||||
|
{
|
||||||
|
if(array.get(i).equals(x))
|
||||||
|
{
|
||||||
|
lastE = array.get(--currentSize);
|
||||||
|
this.arraySet(i, lastE);
|
||||||
|
notFound = false;
|
||||||
|
if(lastE.compareTo(x)>0)
|
||||||
|
{
|
||||||
|
percolateDown(i);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
percolateUp(i);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(notFound)
|
||||||
|
{
|
||||||
|
throw new ElementNotFoundException(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E findMin() throws EmptyPriorityQueueException {
|
public E findMin() throws EmptyPriorityQueueException {
|
||||||
|
|
Loading…
Reference in a new issue