binary search

Виталий Фадеев vital.fadeev at gmail.com
Mon Dec 7 04:09:30 UTC 2020


We have:
     // sorted values
     size_t lines  = [20, 1755, 1756, 1757, 1798, 1824, 1825, 
1839, 1840];
     size_t search = 21;

Goal:
     // Fast find index of the '21' in ordered array 'lines'
     auto found = lines.binarySearch( 20 );     // 0 - index
     auto low   = lines.binarySearchLow( 21 );  // 0 - near lowest 
index

Where is the implementation of "binary search", please?




More information about the Digitalmars-d-learn mailing list