Is there an Iterator implementation that merges multiple iterators?
class MergedIterator<T> implements Iterator<T> { MergedIterator(Iterator<T>... iters) .... }
And the next method should move on to iters[1] when !iters[0].hasNext() etc
I’d call that a ConcatenatedIterator myself – a MergedIterator should merge the results of several iterators e.g. based on sorting
Naming aside, I’m sure there’ll be an implementation in a 3rd party library somewhere. Just off to check Google collections…
EDIT: Bingo – Iterators.concat