Changes in src/libcfa/stdlib.c [a9f2c13:a797e2b1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/stdlib.c
ra9f2c13 ra797e2b1 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 30 15:04:25201613 // Update Count : 16 812 // Last Modified On : Wed Jul 6 14:28:57 2016 13 // Update Count : 169 14 14 // 15 15 … … 200 200 201 201 forall( otype T | { int ?<?( T, T ); } ) 202 T * bsearch( constT key, const T * arr, size_t dimension ) {202 T * bsearch( T key, const T * arr, size_t dimension ) { 203 203 int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; } 204 204 return (T *)bsearch( &key, arr, dimension, sizeof(T), comp ); … … 245 245 246 246 forall( otype T | { int ?<?( T, T ); } ) 247 T min( const T t1, constT t2 ) {247 T min( T t1, T t2 ) { 248 248 return t1 < t2 ? t1 : t2; 249 249 } // min 250 250 251 251 forall( otype T | { int ?>?( T, T ); } ) 252 T max( const T t1, constT t2 ) {252 T max( T t1, T t2 ) { 253 253 return t1 > t2 ? t1 : t2; 254 254 } // max 255 255 256 256 forall( otype T | { T min( T, T ); T max( T, T ); } ) 257 T clamp( const T value, const T min_val, constT max_val ) {257 T clamp( T value, T min_val, T max_val ) { 258 258 return max( min_val, min( value, max_val ) ); 259 259 } // clamp
Note: See TracChangeset
for help on using the changeset viewer.