Changeset 707446a for src/libcfa
- Timestamp:
- Apr 1, 2017, 7:14:11 PM (8 years ago)
- 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
- Location:
- src/libcfa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/stdlib
r24c18ea r707446a 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:03:54 201713 // Update Count : 10 212 // Last Modified On : Sat Apr 1 17:35:24 2017 13 // Update Count : 104 14 14 // 15 15 … … 84 84 forall( otype T | { int ?<?( T, T ); } ) 85 85 T * bsearch( T key, const T * arr, size_t dimension ); 86 forall( otype T | { int ?<?( T, T ); } ) 87 unsigned int bsearch( T key, const T * arr, size_t dimension ); 86 88 87 89 forall( otype T | { int ?<?( T, T ); } ) -
src/libcfa/stdlib.c
r24c18ea r707446a 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:02:22201713 // Update Count : 1 7212 // Last Modified On : Sat Apr 1 18:31:26 2017 13 // Update Count : 181 14 14 // 15 15 … … 228 228 229 229 forall( otype T | { int ?<?( T, T ); } ) 230 unsigned 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 236 forall( otype T | { int ?<?( T, T ); } ) 230 237 void qsort( const T * arr, size_t dimension ) { 231 238 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.