Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to java.util.stream.Streamable?

Early jdk8-ea javadocs like this indicate there was a java.util.stream.Streamable interface, which would appear to have the same relationship to a Stream as Iterable has to an Iterator.

Now it seems like we're stuck with Supplier<Stream>, which is certainly not the same.

What happened to Streamable ?

like image 275
krosenvold Avatar asked Feb 24 '14 11:02

krosenvold


People also ask

Is Java stream blocking?

Java IO's various streams are blocking. That means, that when a thread invokes a read() or write() , that thread is blocked until there is some data to read, or the data is fully written. The thread can do nothing else in the meantime.

What is Java Util stream stream?

Java provides a new additional package in Java 8 called java. util. stream. This package consists of classes, interfaces and enum to allows functional-style operations on the elements. You can use stream by importing java.

Does Java 8 have streams?

Java 8 offers the possibility to create streams out of three primitive types: int, long and double. As Stream<T> is a generic interface, and there is no way to use primitives as a type parameter with generics, three new special interfaces were created: IntStream, LongStream, DoubleStream.

What is stream API in Java 8?

Introduced in Java 8, the Stream API is used to process collections of objects. A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result.


1 Answers

It's been removed some time ago. The rationale for the removal was given by Brian Goetz:

Currently the only implementor is Collection, and all of the other stream-bearing methods are serving up specialized streams (chars(), codePoints(), lines(), etc) with a method name that is more suitable than "stream". So I think we should drop Streamable and leave the stream() / parallel() methods on Collection (or possibly move them up Iterable).

And also:

I'm starting to think that Streamable is not carrying its weight. I'd like to consider dropping Streamable, at which point the base-most implementation of parallel() is in Collection, and I'd also suggest we consider renaming that to parallelStream().

In this other post he adds:

if everything that is Iterable is effectively Streamable (because Iterable has a stream()) method, and everything Streamable is effectively Iterable (because you can turn a Spliterator into an Iterator), aren't they then the same abstraction?

like image 79
assylias Avatar answered Oct 19 '22 07:10

assylias