shellc_c |
Table of contents
Procedureshellc_c ( Shell sort a character array ) void shellc_c ( SpiceInt ndim, SpiceInt arrlen, void * array ) AbstractSort an array of character strings according to the ASCII collating sequence using the Shell Sort algorithm. Required_ReadingNone. KeywordsARRAY SORT Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- ndim I Dimension of the array. arrlen I String length. array I-O The array. Detailed_Inputndim is the number of elements in the array to be sorted. arrlen is the declared length of the strings in the input string array, including null terminators. The input array should be declared with dimension [ndim][arrlen] array on input, is the array to be sorted. Detailed_Outputarray on output, contains the same elements, sorted according to the ASCII collating sequence. The actual sorting is done in place in array. ParametersNone. Exceptions1) If ndim < 2, this routine does not modify the array. 2) If the `array' input array pointer is null, the error SPICE(NULLPOINTER) is signaled. 3) If the `array' input array strings have length less than two characters, the error SPICE(STRINGTOOSHORT) is signaled. FilesNone. ParticularsThe Shell Sort Algorithm is well known. ExamplesLet array contain the following elements: "FEYNMAN" "NEWTON" "EINSTEIN" "GALILEO" "EUCLID" "Galileo" Then after a call to shellc_c, the array would be ordered as follows: "EINSTEIN" "EUCLID" "FEYNMAN" "GALILEO" "Galileo" "NEWTON" Restrictions1) The input array is assumed to be sorted in increasing order. If this condition is not met, the results of bsrchc_c are unpredictable. 2) String comparisons performed by this routine are Fortran-style: trailing blanks in the input array or key value are ignored. This gives consistent behavior with CSPICE code generated by the f2c translator, as well as with the Fortran SPICE Toolkit. Note that this behavior is not identical to that of the ANSI C library functions strcmp and strncmp. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) I.M. Underwood (JPL) Version-CSPICE Version 1.1.0, 05-AUG-2021 (JDR) Changed the input argument name "lenvals" to "arrlen" for consistency with other routines. Edited the header to comply with NAIF standard. -CSPICE Version 1.0.0, 18-JUL-2002 (NJB) (IMU) Index_Entriesshell sort a character array |
Fri Dec 31 18:41:12 2021