Changeset 727cf70f for src/libcfa


Ignore:
Timestamp:
Apr 3, 2017, 12:00:50 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
a6af031
Parents:
23063ea (diff), 1d29d46 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib

    r23063ea r727cf70f  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:03:54 2017
    13 // Update Count     : 102
     12// Last Modified On : Sat Apr  1 17:35:24 2017
     13// Update Count     : 104
    1414//
    1515
     
    8484forall( otype T | { int ?<?( T, T ); } )
    8585T * bsearch( T key, const T * arr, size_t dimension );
     86forall( otype T | { int ?<?( T, T ); } )
     87unsigned int bsearch( T key, const T * arr, size_t dimension );
    8688
    8789forall( otype T | { int ?<?( T, T ); } )
  • src/libcfa/stdlib.c

    r23063ea r727cf70f  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:02:22 2017
    13 // Update Count     : 172
     12// Last Modified On : Sat Apr  1 18:31:26 2017
     13// Update Count     : 181
    1414//
    1515
     
    228228
    229229forall( otype T | { int ?<?( T, T ); } )
     230unsigned int bsearch( T key, const T * arr, size_t dimension ) {
     231        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
     232        T *result = (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
     233        return result ? result - arr : dimension;                       // pointer subtraction includes sizeof(T)
     234} // bsearch
     235
     236forall( otype T | { int ?<?( T, T ); } )
    230237void qsort( const T * arr, size_t dimension ) {
    231238        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
Note: See TracChangeset for help on using the changeset viewer.