Changeset 4040425 for src/libcfa
- Timestamp:
- Mar 2, 2016, 6:15:02 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 36ebd03, b63e376
- Parents:
- 8f610e85
- Location:
- src/libcfa
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/iostream
r8f610e85 r4040425 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 1 6:44:32201613 // Update Count : 8 112 // Last Modified On : Wed Mar 2 18:05:27 2016 13 // Update Count : 85 14 14 // 15 15 … … 19 19 #include "iterator" 20 20 21 context ostream( dtype ostype ) {21 trait ostream( dtype ostype ) { 22 22 _Bool sepPrt( ostype * ); 23 23 void sepOn( ostype * ); … … 35 35 }; 36 36 37 context writeable(type T ) {37 trait writeable( otype T ) { 38 38 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T ); 39 39 }; … … 69 69 70 70 // writes the range [begin, end) to the given stream 71 forall( type elt_type | writeable( elt_type ),type iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )71 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) ) 72 72 void write( iterator_type begin, iterator_type end, os_type *os ); 73 73 74 forall( type elt_type | writeable( elt_type ),type iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )74 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) ) 75 75 void write_reverse( iterator_type begin, iterator_type end, os_type *os ); 76 76 77 77 //--------------------------------------- 78 78 79 context istream( dtype istype ) {79 trait istream( dtype istype ) { 80 80 int fail( istype * ); 81 81 int eof( istype * ); … … 87 87 }; 88 88 89 context readable(type T ) {89 trait readable( otype T ) { 90 90 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T ); 91 91 }; -
src/libcfa/iostream.c
r8f610e85 r4040425 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 1 6:20:57201613 // Update Count : 20 712 // Last Modified On : Wed Mar 2 18:06:35 2016 13 // Update Count : 208 14 14 // 15 15 … … 185 185 //--------------------------------------- 186 186 187 forall( type elttype | writeable( elttype ),type iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )187 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 188 188 void write( iteratortype begin, iteratortype end, ostype *os ) { 189 189 void print( elttype i ) { os | i; } … … 191 191 } // ?|? 192 192 193 forall( type elttype | writeable( elttype ),type iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) )193 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 194 194 void write_reverse( iteratortype begin, iteratortype end, ostype *os ) { 195 195 void print( elttype i ) { os | i; } -
src/libcfa/iterator
r8f610e85 r4040425 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 27 23:49:13201613 // Update Count : 712 // Last Modified On : Wed Mar 2 18:06:05 2016 13 // Update Count : 9 14 14 // 15 15 … … 18 18 19 19 // An iterator can be used to traverse a data structure. 20 context iterator( type iterator_type,type elt_type ) {20 trait iterator( otype iterator_type, otype elt_type ) { 21 21 // point to the next element 22 22 // iterator_type ?++( iterator_type * ); … … 32 32 }; 33 33 34 context iterator_for( type iterator_type, type collection_type,type elt_type | iterator( iterator_type, elt_type ) ) {34 trait iterator_for( otype iterator_type, otype collection_type, otype elt_type | iterator( iterator_type, elt_type ) ) { 35 35 // [ iterator_type begin, iterator_type end ] get_iterators( collection_type ); 36 36 iterator_type begin( collection_type ); … … 38 38 }; 39 39 40 forall( type iterator_type,type elt_type | iterator( iterator_type, elt_type ) )40 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) ) 41 41 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ); 42 42 43 forall( type iterator_type,type elt_type | iterator( iterator_type, elt_type ) )43 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) ) 44 44 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ); 45 45 -
src/libcfa/iterator.c
r8f610e85 r4040425 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jan 26 17:16:07201613 // Update Count : 2 612 // Last Modified On : Wed Mar 2 18:08:11 2016 13 // Update Count : 27 14 14 // 15 15 16 16 #include "iterator" 17 17 18 forall( type iterator_type,type elt_type | iterator( iterator_type, elt_type ) )18 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) ) 19 19 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) { 20 20 for ( iterator_type i = begin; i != end; ++i ) { … … 23 23 } 24 24 25 forall( type iterator_type,type elt_type | iterator( iterator_type, elt_type ) )25 forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) ) 26 26 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) { 27 27 for ( iterator_type i = end; i != begin; ) { -
src/libcfa/prelude.cf
r8f610e85 r4040425 1 # 2 "prelude.cf" // needed for error messages from this file 1 2 // -*- Mode: C -*- 2 3 // … … 8 9 // Created On : Sat Nov 29 07:23:41 2014 9 10 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Mon Jan 4 11:13:26201611 // Update Count : 8 111 // Last Modified On : Wed Mar 2 18:03:41 2016 12 // Update Count : 89 12 13 // 13 14 … … 63 64 long double _Complex ?--( long double _Complex * ), ?--( volatile long double _Complex * ); 64 65 65 forall( type T ) T * ?++( T ** );66 forall( type T ) const T * ?++( const T ** );67 forall( type T ) volatile T * ?++( volatile T ** );68 forall( type T ) const volatile T * ?++( const volatile T ** );69 forall( type T ) T * ?--( T ** );70 forall( type T ) const T * ?--( const T ** );71 forall( type T ) volatile T * ?--( volatile T ** );72 forall( type T ) const volatile T * ?--( const volatile T ** );73 74 forall( type T ) lvalue T ?[?]( T *, ptrdiff_t );75 forall( type T ) const lvalue T?[?]( const T *, ptrdiff_t );76 forall( type T ) volatile lvalue T ?[?]( volatile T *, ptrdiff_t );77 forall( type T ) const volatile lvalue T ?[?]( const volatile T *, ptrdiff_t );78 forall( type T ) lvalue T ?[?]( ptrdiff_t, T * );79 forall( type T ) const lvalue T?[?]( ptrdiff_t, const T * );80 forall( type T ) volatile lvalue T ?[?]( ptrdiff_t, volatile T * );81 forall( type T ) const volatile lvalue T ?[?]( ptrdiff_t, const volatile T * );66 forall( otype T ) T * ?++( T ** ); 67 forall( otype T ) const T * ?++( const T ** ); 68 forall( otype T ) volatile T * ?++( volatile T ** ); 69 forall( otype T ) const volatile T * ?++( const volatile T ** ); 70 forall( otype T ) T * ?--( T ** ); 71 forall( otype T ) const T * ?--( const T ** ); 72 forall( otype T ) volatile T * ?--( volatile T ** ); 73 forall( otype T ) const volatile T * ?--( const volatile T ** ); 74 75 forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t ); 76 forall( otype T ) const lvalue T ?[?]( const T *, ptrdiff_t ); 77 forall( otype T ) volatile lvalue T ?[?]( volatile T *, ptrdiff_t ); 78 forall( otype T ) const volatile lvalue T ?[?]( const volatile T *, ptrdiff_t ); 79 forall( otype T ) lvalue T ?[?]( ptrdiff_t, T * ); 80 forall( otype T ) const lvalue T ?[?]( ptrdiff_t, const T * ); 81 forall( otype T ) volatile lvalue T ?[?]( ptrdiff_t, volatile T * ); 82 forall( otype T ) const volatile lvalue T ?[?]( ptrdiff_t, const volatile T * ); 82 83 83 84 // ------------------------------------------------------------ … … 101 102 long double _Complex ++?( long double _Complex * ), --?( long double _Complex * ); 102 103 103 forall( type T ) T * ++?( T ** );104 forall( type T ) const T * ++?( const T ** );105 forall( type T ) volatile T * ++?( volatile T ** );106 forall( type T ) const volatile T * ++?( const volatile T ** );107 forall( type T ) T * --?( T ** );108 forall( type T ) const T * --?( const T ** );109 forall( type T ) volatile T * --?( volatile T ** );110 forall( type T ) const volatile T * --?( const volatile T ** );111 112 forall( type T ) lvalue T *?( T * );113 forall( type T ) const lvalue T *?( const T * );114 forall( type T ) volatile lvalue T *?( volatile T * );115 forall( type T ) const volatile lvalue T *?( const volatile T * );104 forall( otype T ) T * ++?( T ** ); 105 forall( otype T ) const T * ++?( const T ** ); 106 forall( otype T ) volatile T * ++?( volatile T ** ); 107 forall( otype T ) const volatile T * ++?( const volatile T ** ); 108 forall( otype T ) T * --?( T ** ); 109 forall( otype T ) const T * --?( const T ** ); 110 forall( otype T ) volatile T * --?( volatile T ** ); 111 forall( otype T ) const volatile T * --?( const volatile T ** ); 112 113 forall( otype T ) lvalue T *?( T * ); 114 forall( otype T ) const lvalue T *?( const T * ); 115 forall( otype T ) volatile lvalue T *?( volatile T * ); 116 forall( otype T ) const volatile lvalue T *?( const volatile T * ); 116 117 forall( ftype FT ) lvalue FT *?( FT * ); 117 118 … … 183 184 long double _Complex ?+?( long double _Complex, long double _Complex ), ?-?( long double _Complex, long double _Complex ); 184 185 185 forall( type T ) T * ?+?( T *, ptrdiff_t );186 forall( type T ) T * ?+?( ptrdiff_t, T * );187 forall( type T ) const T * ?+?( const T *, ptrdiff_t );188 forall( type T ) const T * ?+?( ptrdiff_t, const T * );189 forall( type T ) volatile T * ?+?( volatile T *, ptrdiff_t );190 forall( type T ) volatile T * ?+?( ptrdiff_t, volatile T * );191 forall( type T ) const volatile T * ?+?( const volatile T *, ptrdiff_t );192 forall( type T ) const volatile T * ?+?( ptrdiff_t, const volatile T * );193 forall( type T ) T * ?-?( T *, ptrdiff_t );194 forall( type T ) const T * ?-?( const T *, ptrdiff_t );195 forall( type T ) volatile T * ?-?( volatile T *, ptrdiff_t );196 forall( type T ) const volatile T * ?-?( const volatile T *, ptrdiff_t );197 forall( type T ) ptrdiff_t ?-?( const volatile T *, const volatile T * );186 forall( otype T ) T * ?+?( T *, ptrdiff_t ); 187 forall( otype T ) T * ?+?( ptrdiff_t, T * ); 188 forall( otype T ) const T * ?+?( const T *, ptrdiff_t ); 189 forall( otype T ) const T * ?+?( ptrdiff_t, const T * ); 190 forall( otype T ) volatile T * ?+?( volatile T *, ptrdiff_t ); 191 forall( otype T ) volatile T * ?+?( ptrdiff_t, volatile T * ); 192 forall( otype T ) const volatile T * ?+?( const volatile T *, ptrdiff_t ); 193 forall( otype T ) const volatile T * ?+?( ptrdiff_t, const volatile T * ); 194 forall( otype T ) T * ?-?( T *, ptrdiff_t ); 195 forall( otype T ) const T * ?-?( const T *, ptrdiff_t ); 196 forall( otype T ) volatile T * ?-?( volatile T *, ptrdiff_t ); 197 forall( otype T ) const volatile T * ?-?( const volatile T *, ptrdiff_t ); 198 forall( otype T ) ptrdiff_t ?-?( const volatile T *, const volatile T * ); 198 199 199 200 // ------------------------------------------------------------ … … 431 432 forall( ftype FT ) FT * ?=?( FT * volatile *, forall( ftype FT2 ) FT2 * ); 432 433 433 forall( type T ) T * ?+=?( T * *, ptrdiff_t );434 forall( type T ) T * ?+=?( T * volatile *, ptrdiff_t );435 forall( type T ) const T * ?+=?( const T * *, ptrdiff_t );436 forall( type T ) const T * ?+=?( const T * volatile *, ptrdiff_t );437 forall( type T ) volatile T * ?+=?( volatile T * *, ptrdiff_t );438 forall( type T ) volatile T * ?+=?( volatile T * volatile *, ptrdiff_t );439 forall( type T ) const volatile T * ?+=?( const volatile T * *, ptrdiff_t );440 forall( type T ) const volatile T * ?+=?( const volatile T * volatile *, ptrdiff_t );441 forall( type T ) T * ?-=?( T * *, ptrdiff_t );442 forall( type T ) T * ?-=?( T * volatile *, ptrdiff_t );443 forall( type T ) const T * ?-=?( const T * *, ptrdiff_t );444 forall( type T ) const T * ?-=?( const T * volatile *, ptrdiff_t );445 forall( type T ) volatile T * ?-=?( volatile T * *, ptrdiff_t );446 forall( type T ) volatile T * ?-=?( volatile T * volatile *, ptrdiff_t );447 forall( type T ) const volatile T * ?-=?( const volatile T * *, ptrdiff_t );448 forall( type T ) const volatile T * ?-=?( const volatile T * volatile *, ptrdiff_t );434 forall( otype T ) T * ?+=?( T * *, ptrdiff_t ); 435 forall( otype T ) T * ?+=?( T * volatile *, ptrdiff_t ); 436 forall( otype T ) const T * ?+=?( const T * *, ptrdiff_t ); 437 forall( otype T ) const T * ?+=?( const T * volatile *, ptrdiff_t ); 438 forall( otype T ) volatile T * ?+=?( volatile T * *, ptrdiff_t ); 439 forall( otype T ) volatile T * ?+=?( volatile T * volatile *, ptrdiff_t ); 440 forall( otype T ) const volatile T * ?+=?( const volatile T * *, ptrdiff_t ); 441 forall( otype T ) const volatile T * ?+=?( const volatile T * volatile *, ptrdiff_t ); 442 forall( otype T ) T * ?-=?( T * *, ptrdiff_t ); 443 forall( otype T ) T * ?-=?( T * volatile *, ptrdiff_t ); 444 forall( otype T ) const T * ?-=?( const T * *, ptrdiff_t ); 445 forall( otype T ) const T * ?-=?( const T * volatile *, ptrdiff_t ); 446 forall( otype T ) volatile T * ?-=?( volatile T * *, ptrdiff_t ); 447 forall( otype T ) volatile T * ?-=?( volatile T * volatile *, ptrdiff_t ); 448 forall( otype T ) const volatile T * ?-=?( const volatile T * *, ptrdiff_t ); 449 forall( otype T ) const volatile T * ?-=?( const volatile T * volatile *, ptrdiff_t ); 449 450 450 451 _Bool ?=?( _Bool *, _Bool ), ?=?( volatile _Bool *, _Bool ); -
src/libcfa/stdlib
r8f610e85 r4040425 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 1 6:52:25201613 // Update Count : 6 312 // Last Modified On : Wed Mar 2 17:38:21 2016 13 // Update Count : 64 14 14 // 15 15 … … 20 20 } // extern "C" 21 21 22 forall( type T ) T * memset( T * ptr, unsigned char fill ); // use default value '\0' for fill23 forall( type T ) T * memset( T * ptr ); // remove when default value available22 forall( otype T ) T * memset( T * ptr, unsigned char fill ); // use default value '\0' for fill 23 forall( otype T ) T * memset( T * ptr ); // remove when default value available 24 24 25 forall( type T ) T * malloc( void );26 forall( type T ) T * malloc( char fill );27 forall( type T ) T * malloc( T * ptr, size_t size );28 forall( type T ) T * malloc( T * ptr, size_t size, unsigned char fill );29 forall( type T ) T * calloc( size_t size );30 forall( type T ) T * realloc( T * ptr, size_t size );31 forall( type T ) T * realloc( T * ptr, size_t size, unsigned char fill );25 forall( otype T ) T * malloc( void ); 26 forall( otype T ) T * malloc( char fill ); 27 forall( otype T ) T * malloc( T * ptr, size_t size ); 28 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ); 29 forall( otype T ) T * calloc( size_t size ); 30 forall( otype T ) T * realloc( T * ptr, size_t size ); 31 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ); 32 32 33 forall( type T ) T * aligned_alloc( size_t alignment );34 forall( type T ) T * memalign( size_t alignment ); // deprecated35 forall( type T ) int posix_memalign( T ** ptr, size_t alignment );33 forall( otype T ) T * aligned_alloc( size_t alignment ); 34 forall( otype T ) T * memalign( size_t alignment ); // deprecated 35 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ); 36 36 37 37 //--------------------------------------- … … 65 65 //--------------------------------------- 66 66 67 forall( type T | { int ?<?( T, T ); } )67 forall( otype T | { int ?<?( T, T ); } ) 68 68 T * bsearch( const T key, const T * arr, size_t dimension ); 69 69 70 forall( type T | { int ?<?( T, T ); } )70 forall( otype T | { int ?<?( T, T ); } ) 71 71 void qsort( const T * arr, size_t dimension ); 72 72 73 73 //--------------------------------------- 74 74 75 forall( type T | { T ?/?( T, T ); T ?%?( T, T ); } )75 forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } ) 76 76 [ T, T ] div( T t1, T t2 ); 77 77 … … 107 107 //--------------------------------------- 108 108 109 forall( type T | { int ?<?( T, T ); } )109 forall( otype T | { int ?<?( T, T ); } ) 110 110 T min( const T t1, const T t2 ); 111 111 112 forall( type T | { int ?>?( T, T ); } )112 forall( otype T | { int ?>?( T, T ); } ) 113 113 T max( const T t1, const T t2 ); 114 114 115 forall( type T )115 forall( otype T ) 116 116 void swap( T * t1, T * t2 ); 117 117 -
src/libcfa/stdlib.c
r8f610e85 r4040425 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 23 21:02:54201613 // Update Count : 14 212 // Last Modified On : Wed Mar 2 17:38:47 2016 13 // Update Count : 143 14 14 // 15 15 … … 27 27 } // extern "C" 28 28 29 forall( type T ) T * memset( T * ptr, unsigned char fill ) { // use default value '\0' for fill29 forall( otype T ) T * memset( T * ptr, unsigned char fill ) { // use default value '\0' for fill 30 30 printf( "memset1\n" ); 31 31 return (T *)memset( ptr, (int)fill, malloc_usable_size( ptr ) ); 32 32 } // memset 33 forall( type T ) T * memset( T * ptr ) { // remove when default value available33 forall( otype T ) T * memset( T * ptr ) { // remove when default value available 34 34 printf( "memset2\n" ); 35 35 return (T *)memset( ptr, 0, malloc_usable_size( ptr ) ); 36 36 } // memset 37 37 38 forall( type T ) T * malloc( void ) {38 forall( otype T ) T * malloc( void ) { 39 39 printf( "malloc1\n" ); 40 40 return (T *)malloc( sizeof(T) ); 41 41 } // malloc 42 forall( type T ) T * malloc( size_t size ) {42 forall( otype T ) T * malloc( size_t size ) { 43 43 printf( "malloc2\n" ); 44 44 return (T *)(void *)malloc( size ); 45 45 } // malloc 46 forall( type T ) T * malloc( char fill ) {46 forall( otype T ) T * malloc( char fill ) { 47 47 printf( "malloc3\n" ); 48 48 T * ptr = (T *)malloc( sizeof(T) ); … … 50 50 } // malloc 51 51 52 forall( type T ) T * calloc( size_t size ) {52 forall( otype T ) T * calloc( size_t size ) { 53 53 printf( "calloc\n" ); 54 54 return (T *)calloc( size, sizeof(T) ); 55 55 } // calloc 56 56 57 forall( type T ) T * realloc( T * ptr, size_t size ) {57 forall( otype T ) T * realloc( T * ptr, size_t size ) { 58 58 printf( "realloc1\n" ); 59 59 return (T *)(void *)realloc( (void *)ptr, size ); 60 60 } // realloc 61 forall( type T ) T * realloc( T * ptr, size_t size, unsigned char fill ) {61 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ) { 62 62 printf( "realloc2\n" ); 63 63 char * nptr = (T *)(void *)realloc( (void *)ptr, size ); … … 67 67 } // realloc 68 68 69 forall( type T ) T * malloc( T * ptr, size_t size ) {69 forall( otype T ) T * malloc( T * ptr, size_t size ) { 70 70 printf( "malloc4\n" ); 71 71 return (T *)realloc( ptr, size ); 72 72 } // malloc 73 forall( type T ) T * malloc( T * ptr, size_t size, unsigned char fill ) {73 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ) { 74 74 printf( "malloc5\n" ); 75 75 return (T *)realloc( ptr, size, fill ); 76 76 } // malloc 77 77 78 forall( type T ) T * aligned_alloc( size_t alignment ) {78 forall( otype T ) T * aligned_alloc( size_t alignment ) { 79 79 printf( "aligned_alloc\n" ); 80 80 return (T *)memalign( alignment, sizeof(T) ); 81 81 } // aligned_alloc 82 82 83 forall( type T ) T * memalign( size_t alignment ) {83 forall( otype T ) T * memalign( size_t alignment ) { 84 84 printf( "memalign\n" ); 85 85 return (T *)memalign( alignment, sizeof(T) ); 86 86 } // memalign 87 87 88 forall( type T ) int posix_memalign( T ** ptr, size_t alignment ) {88 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ) { 89 89 printf( "posix_memalign\n" ); 90 90 return posix_memalign( (void **)ptr, alignment, sizeof(T) ); … … 212 212 //--------------------------------------- 213 213 214 forall( type T | { int ?<?( T, T ); } )214 forall( otype T | { int ?<?( T, T ); } ) 215 215 T * bsearch( const T key, const T * arr, size_t dimension ) { 216 216 int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; } … … 218 218 } // bsearch 219 219 220 forall( type T | { int ?<?( T, T ); } )220 forall( otype T | { int ?<?( T, T ); } ) 221 221 void qsort( const T * arr, size_t dimension ) { 222 222 int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; } … … 226 226 //--------------------------------------- 227 227 228 forall( type T | { T ?/?( T, T ); T ?%?( T, T ); } )228 forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } ) 229 229 [ T, T ] div( T t1, T t2 ) { /* return [ t1 / t2, t1 % t2 ]; */ } 230 230 … … 257 257 //--------------------------------------- 258 258 259 forall( type T | { int ?<?( T, T ); } )259 forall( otype T | { int ?<?( T, T ); } ) 260 260 T min( const T t1, const T t2 ) { 261 261 return t1 < t2 ? t1 : t2; 262 262 } // min 263 263 264 forall( type T | { int ?>?( T, T ); } )264 forall( otype T | { int ?>?( T, T ); } ) 265 265 T max( const T t1, const T t2 ) { 266 266 return t1 > t2 ? t1 : t2; 267 267 } // max 268 268 269 forall( type T )269 forall( otype T ) 270 270 void swap( T * t1, T * t2 ) { 271 271 T temp = *t1;
Note: See TracChangeset
for help on using the changeset viewer.