Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教下sink之间是倒序查找的,那么如何保证执行操作的正确性? #10

Open
yycer opened this issue Jul 28, 2020 · 1 comment

Comments

@yycer
Copy link

yycer commented Jul 28, 2020

举个例子:

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
Copy link

twwwww commented Sep 15, 2020

只是倒序遍历组装成一个sink,执行的时候还是正序执行的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants