什么是Java 8“视图”? [英] What is a Java 8 "view"?
问题描述
我正在观看Paul Philips的演讲:
I'm watching a talk by Paul Philips :
http://www.youtube.com/watch?v=TS1lpKBMkgg
在12:48他说在Java 8中他们的观点实际上有效比较Scala和Java
at 12:48 he says "in Java 8 their views actually work" when comparing Scala and Java
什么是Java视图以及什么是Scala的等价物?
What are Java "views" and what is Scala's equivalent ?
更新:感谢Daniel的回答我发现这篇文章很有帮助: http://www.scala-lang.org/ docu / files / collections-api / collections_42.html
update : Thanks to Daniel's answer I found this article helpful : http://www.scala-lang.org/docu/files/collections-api/collections_42.html
推荐答案
Java 8的 Stream
是他的意见。它们有两个重要属性:
Java 8's Stream
is what he means by views. They have two important properties:
- 它们是非严格的,这意味着它们只按需生成结果。
- 他们将多个操作融合在一起,因此您可以执行多个
map
或过滤器
调用,并且原始集合仍将只迭代一次。
- They are non-strict, which means they only produce the result on-demand.
- They "fuse" together multiple operations, so you can do multiple
map
orfilter
calls, and the original collection will still be iterated only once.
Scala的等价物是各种视图
集合,您可以通过在现有集合上调用 .view
来获取。他们确实拥有这些属性 - 毕竟它们是定义属性 - 但却充满了缺陷和缺陷,更不用说非常复杂的实现了。
Scala's equivalent are the various View
collections, which you can get by calling .view
on an existing collection. They do have these properties -- they are the defining properties, after all -- but are plagued with deficiencies and bugs, not to mention a very complex implementation.
Paul has玩弄了替代它的实现,但从来没有优先取代它们。
Paul has toyed with alternative implementations for it on and off, but it has never been a priority replacing them.
这篇关于什么是Java 8“视图”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!