Created
March 1, 2016 22:58
-
-
Save sergio-castro/32ebe594dc14614d757e to your computer and use it in GitHub Desktop.
This file contains 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
//A collection of small Java 8 related utility methods, just for the fun of it. | |
public class Java8Tricks { | |
public static <T> Stream<T> stream(Iterator<? extends T> iterator) { | |
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false); | |
} | |
public static <A, B> Iterator<Entry<A, B>> zip(Iterator<? extends A> s1, Iterator<? extends B> s2) { | |
return Iterators.transform(s1, e1 -> immutableEntry(e1, s2.next())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment