流操作分类
中间操作
- 无状态操作【对单个数据进行处理】
filter
map
peek - 有状态操作【对所有的数据进行处理】
dictinct
sorted
limit
终端操作
- 非短路操作
forEach
collect
count - 短路操作
anyMatch
findFirst
findAll
| 中间操作(无状态) | 中间操作(有状态) | 终端操作(短路) | 终端操作(非短路) |
|---|---|---|---|
| 过滤(filter) | 去重(distinct) | 所有匹配(allMatch) | 遍历(forEach) |
| 映射(map) | 跳过(skip) | 任意匹配(anyMatch) | 归约(reduce) |
| 扁平化(flatMap) | 截断(limit) | 不匹配(noneMatch) | 最大值(max) |
| 遍历(peek) | 排序(sorted) | 查找首个(findFirst) | 聚合(collect) |
| 查找任意(findAny) | 最小值(min) | ||
| 计数(count) |