Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 29, 2013 SortedRange | ||||
---|---|---|---|---|
| ||||
I see that SortedRange has a special "contains" method: "Returns true if and only if value can be found in range, which is assumed to be sorted. Performs Ο(log(r.length)) evaluations of pred." Why there's no "find" method? find() inside std.algorithm seems to scan every element inside range. Why doesn't it use a binary search? Andrea |
November 29, 2013 Re: SortedRange | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On 11/29/2013 06:12 AM, Andrea Fontana wrote:
> I see that SortedRange has a special "contains" method:
>
> "Returns true if and only if value can be found in range, which is
> assumed to be sorted. Performs Ο(log(r.length)) evaluations of pred."
>
> Why there's no "find" method?
> find() inside std.algorithm seems to scan every element inside range.
> Why doesn't it use a binary search?
>
> Andrea
Binary search is spelled as SortedRange.lowerBound (and its friends). :)
Ali
|
November 29, 2013 Re: SortedRange | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 29 November 2013 at 16:50:23 UTC, Ali Çehreli wrote:
> On 11/29/2013 06:12 AM, Andrea Fontana wrote:
>> I see that SortedRange has a special "contains" method:
>>
>> "Returns true if and only if value can be found in range, which is
>> assumed to be sorted. Performs Ο(log(r.length)) evaluations of pred."
>>
>> Why there's no "find" method?
>> find() inside std.algorithm seems to scan every element inside range.
>> Why doesn't it use a binary search?
>>
>> Andrea
>
> Binary search is spelled as SortedRange.lowerBound (and its friends). :)
>
> Ali
Why isn't it implemented as static if on std.algorithm find() ?
|
November 29, 2013 Re: SortedRange | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On Friday, November 29, 2013 17:53:07 Andrea Fontana wrote: > Why isn't it implemented as static if on std.algorithm find() ? Open an enhancement request: https://d.puremagic.com - Jonathan M Davis |
Copyright © 1999-2021 by the D Language Foundation