Merge branch 'master' of https://git.etud.insa-toulouse.fr/brunetto/BEGraphes
這個提交存在於:
當前提交
25bb414920
共有 1 個檔案被更改,包括 29 行新增 和 2 行删除
|
|
@ -134,11 +134,38 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
|||
this.arraySet(index, x);
|
||||
this.percolateUp(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
public E findMin() throws EmptyPriorityQueueException {
|
||||
|
|
|
|||
載入中…
新增問題並參考