ceylon.language.ChainedIterator.ceylon Maven / Gradle / Ivy
"An [[Iterator]] that returns the elements of two
[[Iterable]]s, as if they were chained together."
see (`function Iterable.chain`)
by ("Enrique Zamudio")
tagged("Streams")
class ChainedIterator
({Element*} first, {Other*} second)
satisfies Iterator {
variable Iterator iter = first.iterator();
variable value more = true;
shared actual Element|Other|Finished next() {
value element = iter.next();
if (more && element is Finished) {
iter = second.iterator();
more = false;
return iter.next();
}
else {
return element;
}
}
string => "``first``.chain(``second``).iterator()";
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy