INTEGER FUNCTION FINDC( KEY,N, LIST ) INTEGER FUNCTION FIND1( K1, N, LIST1 ) INTEGER FUNCTION FIND2( K1, K2, N, LIST1, LIST2 ) INTEGER FUNCTION FIND3( K1, K2, K3, N, LIST1, LIST2, LIST3 ) INTEGER FUNCTION FIND4( K1, K2, K3, K4, & N, LIST1, LIST2, LIST3, LIST4 ) INTEGER FUNCTION FINDR1( X1, N, XLST1 ) INTEGER FUNCTION FINDR2( X1, X2, N, XLST1, XLST2 ) INTEGER FUNCTION FINDR3( X1, X2, X3, N, XLST1, XLST2, XLST3 ) INTEGER FUNCTION FINDR4( X1, X2, X3, X4, & N, XLST1, XLST2, XLST3, XLST4 ) CHARACTER*(*) KEY ! key INTEGER K1 ! first key INTEGER K2 ! second key INTEGER K3 ! third key INTEGER K4 ! fourth key INTEGER N ! table size CHARACTER*(*) LIST( N ) ! table to search for KEY INTEGER LIST1( N ) ! table to search for K1 INTEGER LIST2( N ) ! table to search for K2 INTEGER LIST3( N ) ! table to search for K3 INTEGER LIST4( N ) ! table to search for K4 INTEGER X1 ! first key INTEGER X2 ! second key INTEGER X3 ! third key INTEGER X4 ! fourth key INTEGER XLST1( N ) ! table to search for K1 INTEGER XLST2( N ) ! table to search for K2 INTEGER XLST3( N ) ! table to search for K3 INTEGER XLST4( N ) ! table to search for K4
int find1c( int k1, int n, const int *list1 ); /** look up integer in sorted key table **/ int find2c( int k1, int k2, int n, const int *list1 , const int *list2 ) ; /** look up <K1,K2> in 2-key table **/ int find3c( int k1, int k2, int k3, int n, const int *list1 , const int *list2 , const int *list3 ) ; /** look up <K1,K2,K3> in 3-key table **/ int find4c( int k1, int k2, int k3, int k4, int n, const int *list1 , const int *list2 , const int *list3 , const int *list4 ) ; /* look up <K1,K2,K3,K4> in 4-key table */ int findr1c( float x1, int n, const float *xlst1 ); /** look up float in sorted key table **/ int findr2c( float x1, float x2, int n, const float *xlst1 , const float *xlst2 ) ; /** look up <X1,X2> in 2-key table **/ int findr3c( float x1, float x2, float x3, int n, const float *xlst1 , const float *xlst2 , const float *xlst3 ) ; /** look up <X1,X2,X3> in 3-key table **/ int findr4c( float x1, float x2, float x3, float x4, int n, const float *xlst1 , const float *xlst2 , const float *xlst3 , const float *xlst4 ) ; /* look up <X1,X2,X3,X4> in 4-key table */
Fortran version returns Fortran subscript (1, ..., N); C version returns C subscript (0, ..., N-1). No C version of FINDC() because of the differences in Fortran and C character-strings.
See also SORTIC, SORTI1, SORTI2, SORTI3, SORTI4, SORTR1, SORTR2, SORTR3, SORTR4 for sorting key-tuple tables, and LOCATC, LOCAT1, LOCAT2, LOCAT3, LOCAT4, LOCATR1, LOCATR2, LOCATR3, LOCATR4 for determining where to insert entries into sorted key-tuple tables.
#include "iodecl3.h"
for C.
Table <N, LIST1, ... > to be searched is sorted in increasing order and does not have duplicates.
... ... INTEGER FIND1 INTEGER KEY INTEGER I INTEGER LIST1( 5 ) DATA LIST1 / 1980, 1983, 1985, 1988, 1990 / ... I = FIND1( KEY, 5, LIST1 ) IF ( I .LT. 0 ) THEN ... KEY not found in LIST1 END IF ...
... #include "iodecl3.h" ... int k1, k2, k3, k4 ; int indx ; ... if ( 0 > ( indx = find4( k1, k2, k3, k4, tablesize, list1, list2, list3, list4 ) ) ) { /** <K1,K2,K3,K4&g not found **/ ... } else{ /** <K1,K2,K3,K4&g found at subscript indx **/ ... } ...
SEE ALSO: LOCAT*
Binary Search-and-Insert Routines
To: Models-3/EDSS I/O API: The Help Pages