Merging one Array with Another

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 2 04:16:29 PDT 2015


On Saturday, 2 May 2015 at 10:18:07 UTC, Per Nordlöw wrote:
> On Friday, 1 May 2015 at 19:30:08 UTC, Ilya Yaroshenko wrote:
>> Both variants are wrong because uniq needs sorted ranges.
>>
>> Probably you need something like that:
>>
>> x = x.chain(y).sort.uniq.array;
>
> Interesting.
>
> Is
>
>     x = x.chain(y).sort
>
> faster than
>
>     x ~= y;
>     x.sort;
>
> ?
>
> If so why?

Probably the latter is slower than the former, at the very least 
because the latter requires memory allocation whereas the former 
does not.


More information about the Digitalmars-d-learn mailing list