SpiceInt card_c ( SpiceCell * cell )
Return the cardinality (current number of elements) in a
cell of any data type.
CELLS
CELLS
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
cell I Input cell.
The function returns the cardinality of the input cell.
cell is a cell of character, double precision, or
integer data type.
The function returns the cardinality of (current number of elements
in) the input cell.
None.
1) If the input cell has invalid cardinality, the error
SPICE(INVALIDCARDINALITY) is signaled. card_c returns
an unspecified value in this case.
2) If the input array has invalid size, the error
SPICE(INVALIDSIZE) is signaled. card_c returns
an unspecified value in this case.
None.
This is a generic function which may be used on SpiceCells of
character, double precision, or integer data type.
The cardinality function card_c is typically used to process
each of the elements of a cell. In the following example, cardc_c
is used to step through the individual elements of the character
cell names.
#include "SpiceUsr.h"
.
.
.
/.
Declare the cell names with string length LNSIZE and maximum
number of strings SIZE.
./
SPICECHAR_CELL ( names, SIZE, LNSIZE );
.
.
.
for ( i = 0; i < card_c(&names); i++ )
{
.
.
.
}
In conjunction with the size_c function, card_c may be used
to predict (and subsequently avoid) overflows when manipulating
cells. In the following example, size_c is used to determine
whether the integer cell original can be safely copied into
the integer cell save before actually attempting the operation.
If original contains more elements than save can hold, then
the operation would fail.
if ( card_c(&original) <= size_c(&save) )
{
copy_c ( &original, &save );
}
else
{
.
.
.
}
None.
None.
N.J. Bachman (JPL)
C.A. Curzon (JPL)
H.A. Neilan (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.0.0, 06-AUG-2002 (NJB) (CAC) (HAN) (WLT) (IMU)
cardinality of an integer cell
Link to routine card_c source file card_c.c
|