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

       appndi_c ( Append an item to an integer cell )

       void appndi_c ( SpiceInt        item,
                       SpiceCell     * cell )

#### Abstract

       Append an item to an integer cell.

#### Required_Reading

       CELLS

#### Keywords

       CELLS

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       item       I   The item to append.
       cell      I-O  The cell to which `item' will be appended.

#### Detailed_Input

       item        is an integer value which is to be appended to `cell'.

       cell        is an integer SPICE cell to which `item' will be
                   appended.

                   `cell' must be declared as an integer SpiceCell.

                   CSPICE provides the following macro, which declares and
                   initializes the cell

                      SPICEINT_CELL           ( cell, CELLSZ );

                   where CELLSZ is the maximum capacity of `cell'.

#### Detailed_Output

       cell        is the input cell with `item' appended. `item' is the last
                   member of `cell'.

                   If `cell' is actually a SPICE set on input and ceases to
                   qualify as a set as result of the requested append
                   operation, the `isSet' member of cell will be set to
                   SPICEFALSE.

#### Parameters

       None.

#### Exceptions

       1)  If the input cell argument doesn't have integer data type,
           the error SPICE(TYPEMISMATCH) is signaled.

       2)  If the cell is not big enough to accommodate the addition
           of a new element, the error SPICE(CELLTOOSMALL) is signaled.

#### Files

       None.

#### Particulars

       None.

#### Examples

       The numerical results shown for this example may differ across
       platforms. The results depend on the SPICE kernels used as
       input, the compiler and supporting libraries, and the machine
       specific arithmetic implementation.

       1) Create a cell for fifteen elements, add a first element to
          it and then append several more integer numbers. Validate
          the cell into a set and print the result. Finally, append
          another integer number. After each operation, check if the
          cell constitutes a set or not.

          Example code begins here.

          /.
             Program appndi_ex1
          ./
          #include <stdio.h>
          #include "SpiceUsr.h"

          int main( )
          {

             /.
             Local constants.
             ./
             #define LISTSZ       9
             #define SETDIM       15

             /.
             Local variables.
             ./
             SPICEINT_CELL      ( a     , SETDIM );
             SpiceInt             i;

             /.
             Set the list of integers to be appended to the cell.
             ./
             SpiceInt             items  [LISTSZ] = { 3,  1,  1 , 2, 5,
                                                      8, 21, 13, 34    };

             /.
             Add a single item to the new cell.
             ./
             appndi_c ( 0, &a );

             /.
             Now insert a list of items.
             ./
             for ( i = 0; i < LISTSZ; i++ )
             {
                appndi_c ( items[i], &a );
             }

             /.
             Output the original contents of cell A.
             ./
             printf( "Items in original set A:\n" );

             for ( i = 0; i < card_c( &a ); i++ )
             {
                printf( "%6d", SPICE_CELL_ELEM_I( &a, i ) );
             }

             printf( " \n" );

             /.
             After the append, does the cell key as a set?
             ./
             if ( a.isSet )
             {
                printf( "Cell is a set after first append\n" );
             }
             else
             {
                printf ( "Cell is not a set after first append\n" );
             }

             /.
             Initialize the set by validating the cell: remove duplicates
             and sort the elements in increasing order.
             ./
             valid_c ( SETDIM, card_c( &a ), &a );

             printf( " \n" );
             printf( "Items in cell A after valid_c:\n" );

             for ( i = 0; i < card_c( &a ); i++ )
             {
                printf( "%6d", SPICE_CELL_ELEM_I( &a, i ) );
             }

             printf( " \n" );

             /.
             After the append, does the cell key as a set?
             ./
             if ( a.isSet )
             {
                printf( "Cell is a set after valid_c\n" );
             }
             else
             {
                printf ( "Cell is not a set after valid_c\n" );
             }

             /.
             Append a new value to the cell, the value being less than all
             other set values.
             ./
             appndi_c ( -22, &a );

             printf( " \n" );
             printf( "Items in cell A after second append:\n" );

             for ( i = 0; i < card_c( &a ); i++ )
             {
                printf( "%6d", SPICE_CELL_ELEM_I( &a, i ) );
             }

             printf( " \n" );

             /.
             After the append, does the cell key as a set?
             ./
             if ( a.isSet )
             {
                printf( "Cell is a set after second append\n" );
             }
             else
             {
                printf ( "Cell is not a set after second append\n" );
             }

             return ( 0 );
          }

          When this program was executed on a Mac/Intel/cc/64-bit
          platform, the output was:

          Items in original set A:
               0     3     1     1     2     5     8    21    13    34
          Cell is not a set after first append

          Items in cell A after valid_c:
               0     1     2     3     5     8    13    21    34
          Cell is a set after valid_c

          Items in cell A after second append:
               0     1     2     3     5     8    13    21    34   -22
          Cell is not a set after second append

#### Restrictions

       None.

#### Literature_References

       None.

#### Author_and_Institution

       N.J. Bachman        (JPL)
       J. Diaz del Rio     (ODC Space)
       H.A. Neilan         (JPL)

#### Version

       -CSPICE Version 1.0.1, 27-AUG-2021 (JDR)

           Edited the header to comply with NAIF standard. Added complete code
           example.

           Extended description of argument "cell" in -Detailed_Input to include
           type and preferred declaration method.

       -CSPICE Version 1.0.0, 01-AUG-2002 (NJB) (HAN)

#### Index_Entries

       append an item to an integer cell

#### Link to routine appndi_c source file appndi_c.c

    Fri Dec 31 18:41:01 2021