java.util.stream.Streamable发生了什么?

前端之家收集整理的这篇文章主要介绍了java.util.stream.Streamable发生了什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
早期的jdk8-ea javadocs like this表示有一个java.util.stream.Streamable接口,它似乎与Iterable对Iterator具有相同的关系.

现在看来,我们被困在供应商< Stream>,这肯定是不一样的.

Streamable发生了什么?

解决方法

之前已经删除了.删除The rationale由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().

this other post他补充说:

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?

猜你在找的Java相关文章