remove BinaryHeap fait / amélioration possible
This commit is contained in:
parent
75097d40da
commit
4ef8a55374
2 changed files with 29 additions and 5 deletions
|
@ -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 {
|
||||
|
|
|
@ -30,7 +30,6 @@ public class Path {
|
|||
* @throws IllegalArgumentException If the list of nodes is not valid, i.e. two
|
||||
* consecutive nodes in the list are not connected in the graph.
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes)
|
||||
throws IllegalArgumentException {
|
||||
|
@ -86,7 +85,6 @@ public class Path {
|
|||
* @throws IllegalArgumentException If the list of nodes is not valid, i.e. two
|
||||
* consecutive nodes in the list are not connected in the graph.
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
||||
throws IllegalArgumentException {
|
||||
|
@ -267,7 +265,6 @@ public class Path {
|
|||
*
|
||||
* @return true if the path is valid, false otherwise.
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue