Binary search

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 14 16:22:37 PST 2015


Is there no way to do a simple binary search of a sorted array 
using Phobos?

I found `SortedRange.contains`, but that just returns true/false. 
I want the index of the element, or the element itself.

I also found `SortedRange.equalRange`, but that sounds like it 
has an unreasonable amount of (admittedly O(1)) overhead for the 
(extremely common) case in which I am looking for only a single 
element, not a range.


More information about the Digitalmars-d-learn mailing list