请教下sink之间是倒序查找的,那么如何保证执行操作的正确性?
yycer opened this issue · comments
yycer commented
举个例子:
String[] s = {"1.0", "2.0", "3.0", "4.0", "5.0"};
Double ans = Stream.of(s)
.map(Double::valueOf)
.filter(d -> d > 2)
.sorted(Comparator.reverseOrder())
.limit(2)
.reduce(Double::sum)
.orElse(0d);
倒序执行第一个Intermediate Operation 时,也就是limit,如何保证不会获取"1.0", "2.0"?
twwwww commented
只是倒序遍历组装成一个sink,执行的时候还是正序执行的。