Ignore:
Timestamp:
Apr 1, 2017, 7:14:11 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
06cf47f
Parents:
24c18ea
Message:

add alternate bsearch returning posn of key

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/searchsort.c

    r24c18ea r707446a  
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  5 18:06:07 2016
    13 // Update Count     : 56
     12// Last Modified On : Sat Apr  1 19:10:12 2017
     13// Update Count     : 62
    1414//
    1515
     
    3535                sout | *v | ", ";
    3636        } // for
     37        sout | endl;
     38        for ( unsigned int i = 0; i < size; i += 1 ) {
     39                unsigned int posn = bsearch( size - i, iarr, size );
     40                sout | iarr[posn] | ", ";
     41        } // for
    3742        sout | endl | endl;
    3843
     
    5459                        sout | *v | ", ";
    5560                } // for
     61                sout | endl;
     62                for ( unsigned int i = 0; i < size; i += 1 ) {
     63                        unsigned int posn = bsearch( size - i, iarr, size );
     64                        sout | iarr[posn] | ", ";
     65                } // for
    5666        }
    5767        sout | endl | endl;
     
    7181                double *v = bsearch( size - i + 0.5, darr, size );
    7282                sout | *v | ", ";
     83        } // for
     84        sout | endl;
     85        for ( unsigned int i = 0; i < size; i += 1 ) {
     86                unsigned int posn = bsearch( size - i + 0.5, darr, size );
     87                sout | darr[posn] | ", ";
    7388        } // for
    7489        sout | endl | endl;
     
    93108                sout | *v | ", ";
    94109        } // for
     110        sout | endl;
     111        for ( unsigned int i = 0; i < size; i += 1 ) {
     112                S temp = { size - i, size - i + 1 };
     113                unsigned int posn = bsearch( temp, sarr, size );
     114                sout | sarr[posn] | ", ";
     115        } // for
    95116        sout | endl | endl;
    96117} // main
Note: See TracChangeset for help on using the changeset viewer.