Kleine Verbesserungen
parent
245b235d43
commit
77f209b2aa
|
@ -24,3 +24,6 @@
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
|
/bin/
|
||||||
|
/.classpath
|
||||||
|
/.project
|
||||||
|
|
|
@ -7,7 +7,6 @@ public class Road {
|
||||||
private final int distance;
|
private final int distance;
|
||||||
|
|
||||||
public Road(City start, City destination, int distance) {
|
public Road(City start, City destination, int distance) {
|
||||||
super();
|
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
|
@ -17,7 +16,7 @@ public class Road {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public City getTarget() {
|
public City getDestination() {
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,7 @@ public class Routeplaner {
|
||||||
|
|
||||||
City startCity = cities.get(start);
|
City startCity = cities.get(start);
|
||||||
startCity.checkAndSetDistance(startCity, startCity, 0);
|
startCity.checkAndSetDistance(startCity, startCity, 0);
|
||||||
LinkedList<Road> connections = startCity.getConnections();
|
candidates.add(startCity);
|
||||||
|
|
||||||
this.processCandidates(startCity, connections, candidates);
|
|
||||||
startCity.setExplored();
|
|
||||||
|
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
|
|
||||||
|
@ -35,7 +32,7 @@ public class Routeplaner {
|
||||||
while (!candidates.isEmpty()) {
|
while (!candidates.isEmpty()) {
|
||||||
City current = candidates.removeFirst();
|
City current = candidates.removeFirst();
|
||||||
|
|
||||||
this.processCandidates(current, current.getConnections(), candidates);
|
this.processCandidates(current, candidates);
|
||||||
current.setExplored();
|
current.setExplored();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +47,9 @@ public class Routeplaner {
|
||||||
return waypoints;
|
return waypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCandidates(City start, LinkedList<Road> connections, TreeSet<City> candidates) {
|
private void processCandidates(City start, TreeSet<City> candidates) {
|
||||||
for (Road r : connections) {
|
for (Road r : start.getConnections()) {
|
||||||
City other = r.getTarget();
|
City other = r.getDestination();
|
||||||
if (other.isExplored())
|
if (other.isExplored())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue