迭代通过集合< List< Integer>> [英] Iterate through Collection<List<Integer>>
本文介绍了迭代通过集合< List< Integer>>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Guava库来生成整数的排列 1
, 2
和 3
。
I use Guava library to generate permutations of integers 1
, 2
and 3
.
Collection<List<Integer>> vehCombinations = Collections2.orderedPermutations(vehicles);
接下来,我需要遍历 vehCombinations
(int j = 0; j< vehCombinations.size(); j ++)检查每个排列:
Next I need to iterate through vehCombinations
and check each permutation with respect to some constraint:
for (int j=0; j<vehCombinations.size(); j++)
{
List<Integer> veh = vehCombinations.get(i);
}
vehCombinations.get(i)
不允许。
那么,如何从 vehCombinations
? b $ b
So, how do I extract permutations from vehCombinations
?
推荐答案
使用foreach,像这样:
Use a foreach, like this:
for(List<Integer> veh : vehCombinations){
veh.doSomething();
}
这篇关于迭代通过集合< List< Integer>>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文