Kleine Verbesserungen

better
hummel 2025-04-15 10:46:59 +02:00
parent 245b235d43
commit 77f209b2aa
3 changed files with 9 additions and 10 deletions

3
.gitignore vendored
View File

@ -24,3 +24,6 @@
hs_err_pid*
replay_pid*
/bin/
/.classpath
/.project

View File

@ -7,7 +7,6 @@ public class Road {
private final int distance;
public Road(City start, City destination, int distance) {
super();
this.start = start;
this.destination = destination;
this.distance = distance;
@ -17,7 +16,7 @@ public class Road {
return start;
}
public City getTarget() {
public City getDestination() {
return destination;
}

View File

@ -24,10 +24,7 @@ public class Routeplaner {
City startCity = cities.get(start);
startCity.checkAndSetDistance(startCity, startCity, 0);
LinkedList<Road> connections = startCity.getConnections();
this.processCandidates(startCity, connections, candidates);
startCity.setExplored();
candidates.add(startCity);
// ---------------------------------------
@ -35,7 +32,7 @@ public class Routeplaner {
while (!candidates.isEmpty()) {
City current = candidates.removeFirst();
this.processCandidates(current, current.getConnections(), candidates);
this.processCandidates(current, candidates);
current.setExplored();
}
@ -50,9 +47,9 @@ public class Routeplaner {
return waypoints;
}
private void processCandidates(City start, LinkedList<Road> connections, TreeSet<City> candidates) {
for (Road r : connections) {
City other = r.getTarget();
private void processCandidates(City start, TreeSet<City> candidates) {
for (Road r : start.getConnections()) {
City other = r.getDestination();
if (other.isExplored())
continue;