kalasoo
2014-08-03 12:14:25 +08:00
```
while(true) {
if (iterator.hasNext()) {
pendingDeals.add(iterator.next());
if (!pendingDeals.isEmpty() && pendingDeals.size() == 10) {
process(pendingDeals);
}
} else {
if (!pendingDeals.isEmpty()) {
process(pendingDeals);
}
break;
}
}
```
或者
```
var end = false; //对不起啊,我Java写的不好,我就把逻辑先放在这里
while(true){
end = !iterator.hasNext();
if ((end || pendingDeals.size() == 10) && !pendingDeals.isEmpty()) {
process(pendingDeals);
}
if (end) {
break;
} else {
pendingDeals.add(iterator.next());
}
}
```