The question but in C#. Alors Java a-t-il la commande C#? J'en ai besoin pour la relation Matches-SearchTerm-Files.Java: parcourir la liste des listes?
foreach(var i in BunchOfItems.SelectMany(k => k.Items)) {}
[Pourquoi pas-boucles?] je l'ai fait ces structures imbriquées pour les boucles, mais ils deviennent bientôt pléthorique. Donc je préfère quelque chose de plus succint comme ci-dessus.
public static Stack<Integer[]> getPrintPoss(String s,File f,Integer maxViewPerF)
{
Stack<File> possPrint = new Stack<File>();
Integer[] poss = new Integer[4]();
int u,size;
for(File f:files)
{
size = f2S(f).length();
u = Math.min(maxViewsPerF,size);
for(int i=0; i<u;i++)
{
// Do something --- bloated, and soon out of control
// wants more succintly
}
}
return possPrint;
}
Cette bibliothèque a une implémentation selectMany() qui ressemblerait à ceci pour vos besoins: for (val i: BunchOfItems.selectMany (bunchItemSelector()) {}. Voir https://github.com/nicholas22/jpropel-light –