| isordv_c |
|
Table of contents
Procedure
isordv_c ( Is array an order vector? )
SpiceBoolean isordv_c ( ConstSpiceInt * array,
SpiceInt n )
AbstractDetermine whether an array of n items contains the integers 0 through n-1. Required_ReadingNone. KeywordsSEARCH SORT UTILITY Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- array I Array of integers. n I Number of integers in array. The function returns SPICETRUE if the array contains the integers 0 through n-1, otherwise it returns SPICEFALSE. Detailed_Input
array is an array of integers. Often this will be an array
that is a candidate order vector to be passed to
a routine for re-ordering some parallel array.
n is the number of elements in array.
Detailed_OutputThe function returns SPICETRUE if the array contains the integers 1 through n. Otherwise it returns SPICEFALSE. ParametersNone. Exceptions
1) If n < 1, the function returns SPICEFALSE.
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 SPICEFALSE.
FilesNone. Particulars
This function provides a simple means of determining whether
or not an array of n integers contains exactly the integers
0 through n-1. An array with this property is called an
"order vector." Order vectors are returned by the CSPICE
routines
orderc_c
orderd_c
orderi_c
and are accepted as input by the CSPICE routines
reordc_c
reordd_c
reordi_c
reordl_c
Examples
1) Suppose you wished to reorder an array of strings based upon
a ranking array supplied by a user. If the ranking array
contains any duplicates or refers to indices that are out
of the range of valid indices for the array of strings,
the attempt to reorder the array of strings cannot succeed.
Its usually better to detect such a possibility before
you begin trying to reorder the array of strings. This routine
will detect the error.
The code fragment below illustrates this idea.
#include "SpiceUsr.h"
.
.
.
if ( isordv_c ( ordvec, n ) )
{
...reorder the input array of strings
reordc_c ( ordvec, n, lenvals, strings );
}
else
{
...state the problem and let the user decide what
to do about it.
.
.
.
}
RestrictionsNone. 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.1.1, 03-AUG-2021 (JDR)
Edited the header to comply with NAIF standard.
-CSPICE Version 1.1.0, 16-FEB-2005 (NJB)
Bug fix: dynamic memory is now freed.
-CSPICE Version 1.0.0, 10-JUL-2002 (NJB) (WLT) (IMU)
Index_Entriestest whether an integer array is an order vector |
Fri Dec 31 18:41:08 2021