public Waypoint getMinOpenWaypoint float minDistance 9999999 Assume th

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public Waypoint getMinOpenWaypoint() {
float minDistance = 9999999; // Assume there is no path longer than this
Waypoint minWaypoint = null; // Initially no waypoint is found
for (Map.Entry<Location, Waypoint> entry : HashMapOpen.entrySet()) {
// Retrieve data from entry
Waypoint currentWaypoint = entry.getValue();
float currentDistance = currentWaypoint.getRemainingCost();
// Update if needed
if (currentDistance < minDistance) {
minDistance = currentDistance;
minWaypoint = currentWaypoint;
}
}
// Return waypoint with minimal distance or null if no entries presented in map
return minWaypoint;
}