1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

make getMostLikely a static method

This commit is contained in:
oblonski 2017-06-29 09:58:38 +02:00
parent 49c8ade5c4
commit f647884184
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -29,6 +29,21 @@ import java.util.*;
*/
public class UnassignedJobReasonTracker implements JobUnassignedListener {
public static String getMostLikely(Frequency reasons) {
if (reasons == null) return "no reason found";
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = reasons.entrySetIterator();
int maxCount = 0;
String mostLikely = null;
while (entryIterator.hasNext()) {
Map.Entry<Comparable<?>, Long> entry = entryIterator.next();
if (entry.getValue() > maxCount) {
Comparable<?> key = entry.getKey();
mostLikely = key.toString();
}
}
return mostLikely;
}
Map<String, Frequency> reasons = new HashMap<>();
Map<Integer, String> codesToReason = new HashMap<>();
@ -141,20 +156,5 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
else return -1;
}
private String getMostLikely(Frequency reasons) {
if (reasons == null) return "no reason found";
Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = reasons.entrySetIterator();
int maxCount = 0;
String mostLikely = null;
while (entryIterator.hasNext()) {
Map.Entry<Comparable<?>, Long> entry = entryIterator.next();
if (entry.getValue() > maxCount) {
Comparable<?> key = entry.getKey();
mostLikely = key.toString();
}
}
return mostLikely;
}
}