Merging one Array with Another

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 8 01:27:17 PDT 2015


On Thursday, 7 May 2015 at 21:53:24 UTC, Per Nordlöw wrote:
> On Thursday, 7 May 2015 at 13:38:23 UTC, Andrea Fontana wrote:
>> Because it is a more generic operation and you can work on a 
>> lazy range.
>> Anyway, to sort and to do uniq it isn't the fastest way.
>>
>> Or maybe I just didn't understand what you really need. :)
>
> Thanks. These are good ideas in general. I'm curious to why
> something like merge isn't already in Phobos. The most similar
> existing range in Phobos is probably
>
> http://dlang.org/phobos/std_range.html#roundRobin
>
> I believe MergeRange will be bi-directional right?
>
> Further, I believe minElement and maxElement at
>
> https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L215
>
> should have a CT-specialization in the case when input is a
> SortedRange. In that case minElement should return front and
> maxElement should return back, right?

Name could be misleading. This is a sortedrange: [4,3,2,1,0]. In 
your case minElement is 4, maxElement is 0 :) On ranges with more 
complex elements sort order can be even less obvious. I think 
first and back it's ok!





More information about the Digitalmars-d-learn mailing list