How to perform Stream functions on an Iterable? [duplicate]

My similar question got marked as duplicate, but here is the helper methods I’ve used to avoid some of the boilerplate:

public static <T> Stream<T> stream(Iterable<T> in) {
    return StreamSupport.stream(in.spliterator(), false);
}

public static <T> Stream<T> parallelStream(Iterable<T> in) {
    return StreamSupport.stream(in.spliterator(), true);
}

Leave a Comment

techhipbettruvabetnorabahisbahis forumu