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

k_smallest[_by]/tail: similarities and differences #904

Closed
Philippe-Cholet opened this issue Mar 18, 2024 · 0 comments · Fixed by #909
Closed

k_smallest[_by]/tail: similarities and differences #904

Philippe-Cholet opened this issue Mar 18, 2024 · 0 comments · Fixed by #909

Comments

@Philippe-Cholet
Copy link
Member

I find my new tail (#899) quite similar to k_smallest and its recent variants: we fuse the iterator, collect a limited number of items, than update the resulting slice with iter.for_each.

In tail, I consume the iterator (doing so can have wanted side effects) even when n = 0 while k_smallest and variants do not but merely drop it.
In tail, I have a special case for n = 1 while k_smallest and variants do not (it could use a possibly faster min[_by]).

I think we should update k_smallest and k_smallest_general accordingly.

Do you see other differences we should fix?

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

Successfully merging a pull request may close this issue.

1 participant