我使用 Guava 库生成整数 1
、2
和 3
的排列。
Collection<List<Integer>> vehCombinations = Collections2.orderedPermutations(vehicles);
接下来我需要遍历 vehCombinations
并根据某些约束检查每个排列:
for (int j=0; j<vehCombinations.size(); j++)
{
List<Integer> veh = vehCombinations.get(i);
}
vehCombinations.get(i)
是不允许的。
那么,如何从 vehCombinations
中提取排列?
最佳答案
使用 foreach,像这样:
for(List<Integer> veh : vehCombinations){
veh.doSomething();
}
关于java - 遍历 Collection<List<Integer>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20654289/