Created
January 13, 2014 17:53
-
-
Save JakeCoxon/8404793 to your computer and use it in GitHub Desktop.
An iterator that iterates two secondary iterators in parallel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CombinedIterator[A, B](first: Iterator[A], second: Iterator[B]) extends Iterator[(Option[A], Option[B])] { | |
def hasNext = first.hasNext || second.hasNext | |
def next = (if (first.hasNext) Some(first.next) else None, if (second.hasNext) Some(second.next) else None) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment