|
Performs a binary search, Numeric of alphanumeric, in a properly sorted array to find a value. If the value is found then its position is returned according SearchMode:
If the searched value is not found then a negative number is returned indicating the position of the first greater value in the array. If we wish we can insert the value in this position. See also its generic version below. |
|
With this generic version of BinSearch we can search on anything, even in a file handled by a File variable. The user can write a local function to return the values the algorithm needs from the searched structure. In the second parameter (NumOfElements) it is defined the number of elements the search operation has to deal. It is assumed that the fist element is at position 1.
In the above example the optional parameter for NumericSearch is omitted. Then FALSE is assumed which means alphanumeric search. NOTE: The structure must be sorted properly according to the returned values by GetValue. For the rest of parameters see its array version above. |