流操作分類
中間操作
- 無狀態操作【對單個數據進行處理】
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) |