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

Fix issue 10777 - multiSort returns SortedRange #4061

Closed
wants to merge 1 commit into from

Conversation

SzMK
Copy link

@SzMK SzMK commented Mar 6, 2016

multiSort!( preds... ) returns SortedRange!( MultiPred!( preds ) ).

MultiPred!( preds... ) combines multiple predicates.
A proposed shrink function allows predicate reduction (a range sorted to preds[1..N] is also sorted to preds[1..(N-1)]).

https://issues.dlang.org/show_bug.cgi?id=10777

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
10777 std.algorithm.multiSort to return a std.range.SortedRange

import std.algorithm.sorting: MultiPred;

static if( is( pred == MultiPred!P, P... ) )
auto shrinkPred( uint n )() {
Copy link
Member

Choose a reason for hiding this comment

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

Think it would be nicer to have this as a freestanding UFCS function. Then you can also put it next to multiSort in std/algorithm/sorting.d.
You should be able to match shrinkPred(less...)(SortedRange!(MultiPred!less) sr).

@MartinNowak
Copy link
Member

Given that many SortedRange functions could be implemented more efficiently using a dedicated MultiSortedRange, we should see SortedRange!(MultiPred!less) as an intermediate solution and not make MultiPred available outside of the package.

@MartinNowak
Copy link
Member

Closed in favor of #4235

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