What would be a good way to compare two Stream instances in Java 8 and find out whether they have the same elements, specifically for purposes of unit testing?<
public static boolean equalStreams(Stream>...streams) {
List>is = Arrays.stream(streams).map(Stream::iterator).collect(Collectors.toList());
while(is.stream().allMatch(Iterator::hasNext))
if(is.stream().map(Iterator::next).distinct().limit(2).count()>1) return false;
return is.stream().noneMatch(Iterator::hasNext);
}