itertools icon indicating copy to clipboard operation
itertools copied to clipboard

implement Iterator::nth for Combinations

Open fyrchik opened this issue 6 years ago • 6 comments

Hello! I have implemented nth method for Combinations iterator.

Closes #301 . Let me know, what do you think. Other changes in tests are due to rustfmt.

fyrchik avatar Feb 02 '19 18:02 fyrchik

I have rebased this on master.

fyrchik avatar Jul 30 '19 06:07 fyrchik

Thanks! I'll take a look at this soon.

jswrenn avatar Jul 31 '19 22:07 jswrenn

@fyrchik I've filed a PR adding a quickcheck test on your feature branch: https://github.com/fyrchik/rust-itertools/pull/1

That test case is finding differences between the output of your specialized Combinations::nth and the current unspecialized method.

The specialized version of Combinations::nth needs to behave identically to the current unspecialized method before I can merge this PR.

jswrenn avatar Aug 02 '19 18:08 jswrenn

I have reimplemented this and got rid of binomial coefficients. We are still advancing iterator one-by-one, however there are no intermediate allocations. I have also added quickcheck tests from @jswrenn to be sure that new implementations behaves similar to the old.

fyrchik avatar Aug 05 '19 17:08 fyrchik

Thanks! Could you resolve the merge conflict? Also, note that the behavior of combinations(0) changed in #383.

jswrenn avatar Jan 20 '20 16:01 jswrenn

I have rebased on master. cargo +nightly test finished successfully.

fyrchik avatar Feb 06 '20 16:02 fyrchik

Hi @fyrchik, Combinations has evolved a bit since you worked on this. Do you want to update your work here? I would promptly respond/review. We now have tests about specializations so I don't think we need your tests.

EDIT: Well, I see all your repositories are archived, I'm closing this. I'll probably make this myself when I find more time unless someone does this before me.

Philippe-Cholet avatar Feb 07 '24 11:02 Philippe-Cholet