SpiceBoolean isordv_c ( ConstSpiceInt * array,
SpiceInt n )
Determine whether an array of n items contains the integers
0 through n-1.
None.
SEARCH
SORT
UTILITY
Variable 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.
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.
The function returns SPICETRUE if the array contains the integers
1 through n. Otherwise it returns SPICEFALSE.
None.
1) If n < 1, the function returns SPICEFALSE.
2) If memory is not available to create a local copy of the order
vector, the error SPICE(MALLOCFAILED) is signaled.
None.
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
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.
.
.
.
}
None.
None.
N.J. Bachman (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-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)
test whether an integer array is an order vector
Link to routine isordv_c source file isordv_c.c
|