Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
isordv_c

Table of contents
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

   isordv_c ( Is array an order vector? ) 

   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 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.

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)
   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_Entries

   test whether an integer array is an order vector
Fri Dec 31 18:41:08 2021