Slide 18
Slide 18 text
Stream Gatherers
● Streamでは、他のデータを参照する処理ができなかった
● スライディングウィンドウなど
● Stream Gathererで可能に
● Gatherersは`collect`に対するCollectorsのように典型処理を
まとめている
jshell> IntStream.range(0, 10).boxed()
.gather(Gatherers.windowFixed(3))
.toList()
$1 ==> [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
jshell> IntStream.range(0, 10).boxed()
.gather(Gatherers.windowSliding(3))
.toList()
$2 ==> [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5],
[4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]
windowFixed windowSliding