/** * Returns a sequential {@code Stream} with this enumerable as its source. * * <p> * The default implementation creates a sequential {@code Stream} from the * collection's {@code Spliterator}. * * @return a sequential {@code Stream} over the elements in this enumerable */ default Stream<E> stream() { return StreamSupport.stream(spliterator(), false); }
/** * Returns a possibly parallel {@code Stream} with this enumerable as its * source. It is allowable for this method to return a sequential stream. * * <p> * The default implementation creates a parallel {@code Stream} from the * enumerable's {@code Spliterator}. * * @return a possibly parallel {@code Stream} over the elements in this * enumerable */ default Stream<E> parallelStream() { return StreamSupport.stream(spliterator(), true); }