Another fun one: partialSort with two ranges
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 3 09:59:34 PST 2015
On 12/03/2015 05:09 PM, Vladimir Panteleev wrote:
> On Thursday, 3 December 2015 at 15:18:16 UTC, Andrei Alexandrescu wrote:
>> This should be pretty cool:
>>
>> https://issues.dlang.org/show_bug.cgi?id=15401
>>
>> Andrei
>
> Does chain not provide random access, thus allowing sorting a chain of
> two ranges?
void partialSort(R,S)(R r,S s)
if(isRandomAccessRange!R && hasLength!R && hasSlicing!R &&
isRandomAccessRange!S && hasLength!S && hasSlicing!S)
{ partialSort(chain(r,s),r.length); }
unittest{
auto a=[1,2,3,4];
auto b=[1,2,3,4,5,6];
partialSort(a,b);
assert(equal(a,[1,1,2,2]));
}
More information about the Digitalmars-d
mailing list