Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/~sontag/spicedocs/cspice/bschoi_c.html
Дата изменения: Sat Dec 17 06:08:32 2005 Дата индексирования: Sun Apr 10 23:57:37 2016 Кодировка: Поисковые слова: m 13 |
Do 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.
None.
VARIABLE 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 value in array, or -1 if the value is not found.
value 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 zero to ndim-1.
The function returns the index of the input value in the input array. Indices range from zero 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.
None.
A 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.
Let array and order contain the following elements: array order ----------- ----- 100 1 1 2 10 0 10000 4 1000 3 Then bschoi_c ( 1000, 5, array, order ) == 4 bschoi_c ( 1, 5, array, order ) == 1 bschoi_c ( 10000, 5, array, order ) == 3 bschoi_c ( -1, 5, array, order ) == -1 bschoi_c ( 17, 5, array, order ) == -1 That is, array[4] == 1000 array[1] == 1 array[3] == 10000
The input order vector is assumed give the order of the elements of the input array in increasing order. If this condition is not met, the results of bschoi_c are unpredictable.
1) If memory cannot be allocated to create a Fortran-style version of the input order vector, the error SPICE(MALLOCFAILED) is signaled. The function returns -1 in this case. 2) If ndim < 1 the value of the function is -1. This is not an error.
None.
N.J. Bachman (JPL) W.L. Taber (JPL) I.M. Underwood (JPL)
None.
-CSPICE Version 1.0.0, 10-JUL-2002 (NJB) (WLT) (IMU)
binary search for an integer value