bschoi_c |

Table of contents## Procedurebschoi_c ( Binary search with order vector, integer ) SpiceInt bschoi_c ( SpiceInt value, SpiceInt ndim, ConstSpiceInt * array, ConstSpiceInt * order ) ## AbstractDo a binary search for a given value within an integer array, accompanied by an order vector. Return the index of the matching array entry, or -1 if the key value is not found. ## Required_ReadingNone. ## KeywordsARRAY SEARCH ## Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- value I Value to find in `array'. ndim I Dimension of `array'. array I Array to be searched. order I Order vector. The function returns the index of the first matching array element or -1 if the value is not found. ## Detailed_Inputvalue is the value to be found in the input array. ndim is the number of elements in the input array. array is the array to be searched. order is an order vector which can be used to access the elements of `array' in order. The contents of order are a permutation of the sequence of integers ranging from 0 to ndim-1. ## Detailed_OutputThe function returns the index of the specified value in the input array. Indices range from 0 to ndim-1. If the input array does not contain the specified value, the function returns -1. If the input array contains more than one occurrence of the specified value, the returned index may point to any of the occurrences. ## ParametersNone. ## Exceptions1) If ndim < 1, the value of the function is -1. 2) If memory cannot be allocated to create the temporary variable required for the execution of the underlying Fortran routine, the error SPICE(MALLOCFAILED) is signaled. The function returns the value -1. ## FilesNone. ## ParticularsA binary search is performed on the input array, whose order is given by an associated order vector. If an element of the array is found to match the input value, the index of that element is returned. If no matching element is found, -1 is returned. ## ExamplesLet `array' and `order' contain the following elements: array order ----------- ----- 100 1 1 2 10 0 10000 4 1000 3 Then ## Restrictions1) `order' is assumed to give the order of the elements of `array' in increasing order. If this condition is not met, the results of ## Literature_ReferencesNone. ## Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) I.M. Underwood (JPL) ## Version-CSPICE Version 1.0.1, 08-JUL-2021 (JDR) Edited the header to comply with NAIF standard. Updated -Index_Entries to better explain the objective of this function. -CSPICE Version 1.0.0, 10-JUL-2002 (NJB) (WLT) (IMU) ## Index_Entriesbinary search for an integer using an order vector |

Fri Dec 31 18:41:02 2021