前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Stream operations and pipelines - intermediate operation

Stream operations and pipelines - intermediate operation

作者头像
MickyInvQ
发布2021-06-24 11:14:51
2360
发布2021-06-24 11:14:51
举报
文章被收录于专栏:InvQ的专栏

Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections. For example:

代码语言:javascript
复制
 int sum = widgets.stream()
                  .filter(b -> b.getColor() == RED)
                  .mapToInt(b -> b.getWeight())
                  .sum();

Here we use widgets, a Collection, as a source for a stream, and then perform a filter-map-reduce on the stream to obtain the sum of the weights of the red widgets. (Summation is an example of a reduction operation.)

比如使用在一个集合上使用map-reduce操作,如上所示,我们先把widget类型的集合作为数据源,然后执行filter、map、以及sum。最后实现了,统计红色部件的总重量。 The key abstraction introduced in this package is stream. Streams differ from collections in several ways: 如下主要讲解stream的一些特性,stream和集合主要有以下不同的几点:

  • No storage. A stream is not a data structure that stores elements; instead, it conveys elements from a source such as a da
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/06/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档