Kla*_*sos 1 java collections guava
我使用Guava库来生成整数的排列1,2并且3.
Collection<List<Integer>> vehCombinations = Collections2.orderedPermutations(vehicles);
Run Code Online (Sandbox Code Playgroud)
接下来,我需要迭代vehCombinations并检查关于某些约束的每个排列:
for (int j=0; j<vehCombinations.size(); j++)
{
List<Integer> veh = vehCombinations.get(i);
}
Run Code Online (Sandbox Code Playgroud)
vehCombinations.get(i) 不被允许.
那么,我如何从中提取排列vehCombinations?
小智 5
使用foreach,如下所示:
for(List<Integer> veh : vehCombinations){
veh.doSomething();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |