extend "in" to all array types

Jakob Ovrum jakobovrum at gmail.com
Wed Jan 15 21:15:17 PST 2014


On Wednesday, 15 January 2014 at 18:57:15 UTC, Ali Çehreli wrote:
> On 01/15/2014 07:38 AM, Adam D. Ruppe wrote:
>
> > Probably not, since there's a significant speed difference
> between in
> > associative array and in regular array. For a regular array,
> it means
> > potentially looping over every item in the array.
>
> And a specialization for std.range.SortedRange would use binary 
> search:
>
>   http://dlang.org/phobos/std_range.html#.SortedRange
>
> Ali

I'm for it, but it would have to have the explicit caveat that it 
would only return a pointer to the *first* equal element in the 
list, as there may be duplicates. If we instead return a range, 
then suddenly we have `std.algorithm.find`.

Maybe `findSplit` should also have a specialization for 
`SortedRange` that uses `SortedRange.trisect`.


More information about the Digitalmars-d mailing list