The question but in C#. Vậy Java có lệnh C# không? Tôi cần nó cho Matches-SearchTerm-Files-relationship.Java: lặp qua danh sách các danh sách?
foreach(var i in BunchOfItems.SelectMany(k => k.Items)) {}
[Tại sao không cho-vòng?] Tôi đã làm cấu trúc như vậy trong lồng nhau cho vòng nhưng họ sớm trở thành cồng kềnh. Vì vậy, tôi thích một cái gì đó succint hơn như trên.
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;
}
Thư viện này có triển khai selectMany() trông giống như thế này cho yêu cầu của bạn: cho (val i: BunchOfItems.selectMany (bunchItemSelector()) {}. Xem https://github.com/nicholas22/jpropel-light –