- class
InterleavingIterator
(T): Iterator!(T);
- InterleavingIterators allow you to combine the elements
of two different enumerations as if they were one enumeration
before they are seen by their `consumers'.
This sometimes allows you to avoid having to use a
Collection object to temporarily combine two sets of Collection elements()
that need to be collected together for common processing.
The elements are revealed (via get()) in a purely
interleaved fashion, alternating between the first and second
enumerations unless one of them has been exhausted, in which case
all remaining elements of the other are revealed until it too is
exhausted.
InterleavingIterators work as wrappers around other Iterators.
To build one, you need two existing Iterators.
For example, if you want to process together the elements of
two Collections a and b, you could write something of the form:
Iterator items =
InterleavingIterator
(a.elements(), b.elements());
while (items.more())
doSomethingWith(items.get());
author:
Doug Lea
@version 0.93
For an introduction to this package see Overview .
- Iterator!(T)
fst_
;
- The first source; nulled out once it is exhausted
- Iterator!(T)
snd_
;
- The second source; nulled out once it is exhausted
- Iterator!(T)
current_
;
- The source currently being used
- this(Iterator!(T) fst, Iterator!(T) snd);
- Make an enumeration interleaving elements from fst and snd
- bool
more
();
- Implements tango.util.collection.model.Iterator.
more
- T
get
();
- Implements tango.util.collection.model.Iterator.
get
.
- void
flip
();
- Alternate sources
|