static ItIt roundRobinCombinedIterator(Iterator... iterators) {
ret roundRobinCombinedIterator(wrapAsList(iterators));
}
static ItIt roundRobinCombinedIterator(Cl extends Iterator> iterators) {
if (empty(iterators)) ret emptyItIt();
class Robin implements IF0 {
L extends Iterator> activeIterators = cloneList(iterators);
int i;
public O get() {
while licensed {
Iterator it = activeIterators.get(i);
if (!it.hasNext()) {
activeIterators.remove(i);
if (empty(activeIterators)) break;
i %= l(activeIterators);
} else {
i = (i+1) % l(activeIterators);
ret it.next();
}
}
ret endMarker();
}
}
ret iff(new Robin);
}