-
Notifications
You must be signed in to change notification settings - Fork 310
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
combinations: count
and size_hint
#729
combinations: count
and size_hint
#729
Conversation
Because we give combinations in the lexicographic order, we can use the indices to count the remaining combinations to come. We are gonna heavily test it thought.
The whole point of the lazy buffer is to not fill the pool all at once but in some cases we want to, and then it's better than do it with `while lazy_buffer.get_next() {}` that would be weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Philippe-Cholet I tried to review, and I have some questions.
I think the most difficult part for me is to understand remaining_for
.
`pool.it.count()` consumes `pool` before we call `remaining_for` so it can not be a method and therefore becomes a free function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. We should comment the sources for the complex algorithms and add some tests, then I think we're good to go.
And add todo
Only test for `n <= 500` but only a few values of the last row do not already have overflow on a 64 bits computer. NOTE: Not faster with an array updated in-place.
All changes are done (with a limit of 500 for Ready to squash everything into one commit. |
The indices we track (to give combinations in the lexicographic order) can help us count the remaining combinations.
@phimuemue That's all for combinations. Each commit is as small as possible. Similar work for other iterators to come, but this should be the biggest as it prepares work for
powerset
andcombinations_with_replacement
.