Implement Launch.main() and BinaryHeap.remove()
This commit is contained in:
parent
bda9d62799
commit
53e9facf47
2 changed files with 14 additions and 11 deletions
|
@ -137,7 +137,11 @@ 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 index = array.indexOf(x);
|
||||||
|
if (index == -1 || index >= currentSize) throw new ElementNotFoundException(x);
|
||||||
|
arraySet(index, array.get(--currentSize));
|
||||||
|
percolateUp(index);
|
||||||
|
percolateDown(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.insa.graphs.gui.drawing.components.BasicDrawing;
|
||||||
import org.insa.graphs.model.Graph;
|
import org.insa.graphs.model.Graph;
|
||||||
import org.insa.graphs.model.Path;
|
import org.insa.graphs.model.Path;
|
||||||
import org.insa.graphs.model.io.BinaryGraphReader;
|
import org.insa.graphs.model.io.BinaryGraphReader;
|
||||||
|
import org.insa.graphs.model.io.BinaryPathReader;
|
||||||
import org.insa.graphs.model.io.GraphReader;
|
import org.insa.graphs.model.io.GraphReader;
|
||||||
import org.insa.graphs.model.io.PathReader;
|
import org.insa.graphs.model.io.PathReader;
|
||||||
|
|
||||||
|
@ -46,28 +47,26 @@ public class Launch {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
// Visit these directory to see the list of available files on Commetud.
|
// Visit these directory to see the list of available files on Commetud.
|
||||||
final String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
final String mapName = "maps/insa.mapgr";
|
||||||
final String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path";
|
final String pathName = "maps/path_fr31insa_rangueil_insa.path";
|
||||||
|
|
||||||
// Create a graph reader.
|
// Create a graph reader.
|
||||||
final GraphReader reader = new BinaryGraphReader(
|
final GraphReader reader = new BinaryGraphReader(
|
||||||
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
|
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
|
||||||
|
|
||||||
// TODO: Read the graph.
|
final Graph graph = reader.read();
|
||||||
final Graph graph = null;
|
|
||||||
|
|
||||||
// Create the drawing:
|
// Create the drawing:
|
||||||
final Drawing drawing = createDrawing();
|
final Drawing drawing = createDrawing();
|
||||||
|
|
||||||
// TODO: Draw the graph on the drawing.
|
drawing.drawGraph(graph);
|
||||||
|
|
||||||
// TODO: Create a PathReader.
|
final PathReader pathReader = new BinaryPathReader(
|
||||||
final PathReader pathReader = null;
|
new DataInputStream(new BufferedInputStream(new FileInputStream(pathName))));
|
||||||
|
|
||||||
// TODO: Read the path.
|
final Path path = pathReader.readPath(graph);
|
||||||
final Path path = null;
|
|
||||||
|
|
||||||
// TODO: Draw the path.
|
drawing.drawPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue