Merging one Array with Another

Ilya Yaroshenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 1 12:30:03 PDT 2015


Both variants are wrong because uniq needs sorted ranges.

Probably you need something like that:

x = x.chain(y).sort.uniq.array;

On Friday, 1 May 2015 at 19:08:51 UTC, Per Nordlöw wrote:
> What's the fastest Phobos-way of doing either
>
>     x ~= y; // append
>     x = x.uniq; // remove duplicates
>
> or
>
>     x = (x ~ y).uniq; // append and remove duplicates in one go
>
> provided that
>
>     T[] x, y;
>
> ?


More information about the Digitalmars-d-learn mailing list