mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
enhance RandomUtils
This commit is contained in:
parent
f8f063773a
commit
2acfad31ba
1 changed files with 10 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import jsprit.core.problem.job.Job;
|
|||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
|
|
@ -19,6 +20,10 @@ public class RandomUtils {
|
|||
return nextItem(jobs,random);
|
||||
}
|
||||
|
||||
public static Job nextJob(List<Job> jobs, Random random){
|
||||
return nextItem(jobs,random);
|
||||
}
|
||||
|
||||
public static <T> T nextItem(Collection<T> items, Random random){
|
||||
int randomIndex = random.nextInt(items.size());
|
||||
int count = 0;
|
||||
|
|
@ -29,4 +34,9 @@ public class RandomUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static <T> T nextItem(List<T> items, Random random){
|
||||
int randomIndex = random.nextInt(items.size());
|
||||
return items.get(randomIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue