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

Implement ranges::sample and ranges::shuffle #1052

Merged
merged 17 commits into from
Jul 27, 2020

Conversation

miscco
Copy link
Contributor

@miscco miscco commented Jul 17, 2020

This ports the sampling algorithm to ranges.

I am unsure what exactly the problem is with the tests. I guess somecombinations of the machinery do not play well with the requirements but I have to figure out which.

@miscco miscco requested a review from a team as a code owner July 17, 2020 12:42
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
@CaseyCarter CaseyCarter added cxx20 C++20 feature ranges C++20/23 ranges labels Jul 17, 2020
@CaseyCarter CaseyCarter mentioned this pull request Jul 17, 2020
@StephanTLavavej
Copy link
Member

Thanks for the initial review, @statementreply! 😸 Moving to WIP as you've identified the cause of (at least one of) the test failures (mentioning a nonexistent _It).

@miscco
Copy link
Contributor Author

miscco commented Jul 19, 2020

It seems activating the tests actually helps...

@miscco miscco changed the title Implement ranges::sample Implement ranges::sample and ranges::sample Jul 19, 2020
@miscco miscco changed the title Implement ranges::sample and ranges::sample Implement ranges::sample and ranges::shuffle Jul 19, 2020
@miscco
Copy link
Contributor Author

miscco commented Jul 19, 2020

Given that we move the concept definition into algorithm I have put the ranges::shuffle implementation into this PR as otherwise merging is a hassle and both are similar anyway

@miscco
Copy link
Contributor Author

miscco commented Jul 19, 2020

Tests are active and passing so this should be ready for review

stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_sample/test.cpp Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_sample/test.cpp Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_shuffle/test.cpp Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_shuffle/test.cpp Outdated Show resolved Hide resolved
stl/inc/algorithm Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick which I'll go ahead and apply.

stl/inc/algorithm Outdated Show resolved Hide resolved
Avoid contextually converting integer to bool.
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good modulo comments, thanks!

tests/std/tests/P0896R4_ranges_alg_sample/test.cpp Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_shuffle/test.cpp Outdated Show resolved Hide resolved
stl/inc/algorithm Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_sample/test.cpp Outdated Show resolved Hide resolved
tests/std/tests/P0896R4_ranges_alg_sample/test.cpp Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej removed their assignment Jul 23, 2020
@CaseyCarter CaseyCarter self-assigned this Jul 27, 2020
@CaseyCarter CaseyCarter merged commit 99241dc into microsoft:master Jul 27, 2020
@CaseyCarter
Copy link
Member

Thanks for implementing these algorithms, whose choice I suspect was actually quite deliberate - not random at all.

@CaseyCarter CaseyCarter removed their assignment Jul 27, 2020
@miscco miscco deleted the ranges_sample branch July 27, 2020 18:48
CaseyCarter pushed a commit to CaseyCarter/STL that referenced this pull request Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cxx20 C++20 feature ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants