remove BinaryHeap fait / amélioration possible

This commit is contained in:
Marie Brunetto 2023-03-29 16:20:32 +02:00
parent 75097d40da
commit 4ef8a55374
2 changed files with 29 additions and 5 deletions

View file

@ -137,8 +137,35 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
@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 {

View file

@ -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() {