removi_c |
Table of contents
Procedureremovi_c ( Remove an item from an integer set ) void removi_c ( SpiceInt item, SpiceCell * a ) AbstractRemove an item from an integer set. Required_ReadingSETS KeywordsCELLS SETS Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- item I Item to be removed. a I-O Removal set. Detailed_Inputitem is an item which is to be removed from the specified set. `item' may or may not already be an element of the set. a is a SPICE set. On input, `a' may or may not contain the input item as an element. `a' must be declared as an integer SpiceCell. CSPICE provides the following macro, which declares and initializes the cell SPICEINT_CELL ( a, ASZ ); where ASZ is the maximum capacity of `a'. Detailed_Outputa on output, contains the difference of the input set and the input item. If the item is not an element of the set, the set is not changed. ParametersNone. Exceptions1) The data values in set `a' must be monotone strictly increasing. This is not checked. If this condition is not met, the results are unpredictable. 2) If the `a' cell argument has a type other than SpiceInt, the error SPICE(TYPEMISMATCH) is signaled. 3) If the `a' cell argument does not qualify as a SPICE set, the error SPICE(NOTASET) is signaled. SPICE sets have their data elements stored in increasing order and contain no duplicate elements. FilesNone. ParticularsNone. ExamplesThe 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 an integer set for ten elements, insert items to it and then remove the even values. Example code begins here. /. Program removi_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local constants. ./ #define SETDIM 10 /. Local variables. ./ SPICEINT_CELL ( a , SETDIM ); SpiceInt i; /. Create a list of items and even numbers. ./ SpiceInt even [SETDIM] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 }; SpiceInt items [SETDIM] = { 0, 1, 1, 2, 3, 5, 8, 10, 13, 21 }; /. Initialize the empty set. ./ valid_c ( SETDIM, 0, &a ); /. Insert the list of integers into the set. If the item is an element of the set, the set is not changed. ./ for ( i = 0; i < SETDIM; i++ ) { insrti_c ( items[i], &a ); } /. Output the original contents of set `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" ); /. Remove the even values. If the item is not an element of the set, the set is not changed. ./ for ( i = 0; i < SETDIM; i++ ) { removi_c ( even[i], &a ); } /. Output the contents of `a'. ./ printf( "Odd numbers in set A:\n" ); for ( i = 0; i < card_c( &a ); i++ ) { printf( "%6d", SPICE_CELL_ELEM_I( &a, i ) ); } printf( " \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 1 2 3 5 8 10 13 21 Odd numbers in set A: 1 3 5 13 21 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) C.A. Curzon (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) I.M. Underwood (JPL) Version-CSPICE Version 1.1.0, 24-AUG-2021 (JDR) Changed the argument name "set" to "a" for consistency with other routines. Edited the header to comply with NAIF standard. Added complete code example. Extended description of argument "a" in -Detailed_Input to include type and preferred declaration method. Added entry #1 in -Exceptions section. -CSPICE Version 1.0.0, 07-AUG-2002 (NJB) (CAC) (WLT) (IMU) Index_Entriesremove an item from an integer set |
Fri Dec 31 18:41:11 2021