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:
parent
49c8ade5c4
commit
f647884184
1 changed files with 15 additions and 15 deletions
|
|
@ -29,6 +29,21 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
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<String, Frequency> reasons = new HashMap<>();
|
||||||
|
|
||||||
Map<Integer, String> codesToReason = new HashMap<>();
|
Map<Integer, String> codesToReason = new HashMap<>();
|
||||||
|
|
@ -141,20 +156,5 @@ public class UnassignedJobReasonTracker implements JobUnassignedListener {
|
||||||
else return -1;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue