Index Page isordv_c
A B C D E F G H I J K L M N O P Q R S T U V W X
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       SpiceBoolean isordv_c ( ConstSpiceInt  * array,
                               SpiceInt         n      )
#### Abstract
       Determine whether an array of n items contains the integers
       0 through n-1.
#### Required_Reading
       None.
#### Keywords
       SEARCH
       SORT
       UTILITY
#### Brief_I/O
       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.
#### 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_Output
       The function returns SPICETRUE if the array contains the integers
       1 through n.  Otherwise it returns SPICEFALSE.
#### Parameters
       None.
#### Exceptions
       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.
#### Files
       None.
#### 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.
                      .
                      .
                      .
             }
#### Restrictions
       None.
#### Literature_References
       None.
#### Author_and_Institution
       N.J. Bachman   (JPL)
       W.L. Taber     (JPL)
       I.M. Underwood (JPL)
#### Version
       -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_Entries
       test whether an integer array is an order vector
#### Link to routine isordv_c source file isordv_c.c

    Wed Jun  9 13:05:25 2010