1/8/2024 0 Comments Parametic polymorphism javaThe various actual functions could have different code, and in this case, only the INTEGER*4 THIS,NUMB(1:*) need be changed, say to REAL*4 THIS,NUMB(1:*) for FINDF4, which is why both variables are named in the one statement. There would be a function (with a unique name) for each of the contemplated variations in parameter types, and when the compiler reached an invocation of FIND(.) it would select by matching amongst the combinations that had been defined in the routines named in the INTERFACE statement. Caught it ! THIS = NUMB(P) 4 FINDI4 = P !So, THIS is found, here! END FUNCTION FINDI4 !On success, THIS = NUMB(FINDI4) no fancy index here. 3 R = P !Shift the right bound down: THIS precedes NUMB(P). 2 L = P !Shift the left bound up: THIS follows NUMB(P). IF ( THIS - NUMB ( P )) 3, 4, 2 !Compare to the probe point. P = P + L !Convert from offset to probe point. FINDI4 = - L !Having -L rather than 0 (or other code) might be of interest. 0 ) THEN !Aha! Nowhere! And THIS follows NUMB(L). R = N + 1 !One before, and one after, the first and last. In other versions, it is supplied by the index. INTEGER * 4 THIS, NUMB ( 1 : * ) !Where is THIS in array NUMB(1:N)? INTEGER N !The count. INTENT ( IN ) THIS, NUMB, N !Imply read-only, but definitely no need for any "copy-back". Find i such that THIS = NUMB(i) USE ASSISTANCE !Only for the trace stuff. END INTERFACE FIND CONTAINS INTEGER FUNCTION FINDI4 ( THIS, NUMB, N ) !Binary chopper. MODULE PROCEDURE 1 FINDI4, !I: of integers. INTERFACE FIND !Binary chop search, not indexed. MODULE SORTSEARCH !Genuflect towards Prof. #include #include #define decl_tree_type(T) \ typedef struct node_#T#_t node_#T#_t, *node_#T \ struct node_#T#_t
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |