Changeset 2a092d6 for tests/searchsort.cfa
 Timestamp:
 Dec 20, 2018, 12:00:13 PM (5 years ago)
 Branches:
 ADT, aaronthesis, armeh, astexperimental, cleanupdtors, deferred_resn, enum, forallpointerdecay, jacob/cs343translation, jenkinssandbox, master, newast, newastuniqueexpr, no_list, persistentindexer, pthreademulation, qualifiedEnum
 Children:
 1b34b87
 Parents:
 6ebc13f
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

tests/searchsort.cfa
r6ebc13f r2a092d6 21 21 22 22 int main( void ) { 23 const unsignedint size = 10;23 const int size = 10; 24 24 int iarr[size]; 25 25 26 26 sout  nlOff; // turn off auto newline 27 27 28 for ( i; 0 u~ size ) {28 for ( i; 0 ~ size ) { 29 29 iarr[i] = size  i; 30 30 sout  iarr[i]  ", "; … … 34 34 // ascending sort/search by changing < to > 35 35 qsort( iarr, size ); 36 for ( i; 0 u~ size ) {36 for ( i; 0 ~ size ) { 37 37 sout  iarr[i]  ", "; 38 38 } // for 39 39 sout  nl; 40 for ( i; 0 u~ size ) { // C version40 for ( i; 0 ~ size ) { // C version 41 41 int key = size  i; 42 42 int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp ); … … 45 45 sout  nl; 46 46 47 for ( i; 0 u~ size ) {47 for ( i; 0 ~ size ) { 48 48 int * v = bsearch( size  i, iarr, size ); 49 49 sout  size  i  ':'  *v  ", "; 50 50 } // for 51 51 sout  nl; 52 for ( i; 0 u~ size ) {52 for ( i; 0 ~ size ) { 53 53 unsigned int posn = bsearch( size  i, iarr, size ); 54 54 sout  size  i  ':'  iarr[posn]  ", "; … … 63 63 sout  nl; 64 64 { 65 int ?<?( int x, int y ) { return x > y; } 66 qsort( iarr, size ); 67 for ( i; 0u ~ size ) { 65 // redefinition of ?<? can't overlap the loop controls: 66 { 67 int (*?<?)(int, int) = ?>?; 68 qsort( iarr, size ); 69 } 70 for ( i; 0 ~ size ) { 68 71 sout  iarr[i]  ", "; 69 72 } // for 70 73 sout  nl; 71 for ( i; 0u ~ size ) { 74 for ( i; 0 ~ size ) { 75 int (*?<?)(int, int) = ?>?; 72 76 int * v = bsearch( size  i, iarr, size ); 73 77 sout  size  i  ':'  *v  ", "; 74 78 } // for 75 79 sout  nl; 76 for ( i; 0u ~ size ) { 80 for ( i; 0 ~ size ) { 81 int (*?<?)(int, int) = ?>?; 77 82 unsigned int posn = bsearch( size  i, iarr, size ); 78 83 sout  size  i  ':'  iarr[posn]  ", "; … … 82 87 83 88 double darr[size]; 84 for ( i; 0 u~ size ) {89 for ( i; 0 ~ size ) { 85 90 darr[i] = size  i + 0.5; 86 91 sout  darr[i]  ", "; … … 88 93 sout  nl; 89 94 qsort( darr, size ); 90 for ( i; 0 u~ size ) {95 for ( i; 0 ~ size ) { 91 96 sout  darr[i]  ", "; 92 97 } // for 93 98 sout  nl; 94 for ( i; 0 u~ size ) {99 for ( i; 0 ~ size ) { 95 100 double * v = bsearch( size  i + 0.5, darr, size ); 96 101 sout  size  i + 0.5  ':'  *v  ", "; 97 102 } // for 98 103 sout  nl; 99 for ( i; 0 u~ size ) {104 for ( i; 0 ~ size ) { 100 105 unsigned int posn = bsearch( size  i + 0.5, darr, size ); 101 106 sout  size  i + 0.5  ':'  darr[posn]  ", "; … … 106 111 int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; } 107 112 ofstream & ??( ofstream & os, S v ) { return os  v.i  ' '  v.j; } 108 for ( i; 0 u~ size ) {113 for ( i; 0 ~ size ) { 109 114 sarr[i].i = size  i; 110 115 sarr[i].j = size  i + 1; … … 113 118 sout  nl; 114 119 qsort( sarr, size ); 115 for ( i; 0 u~ size ) {120 for ( i; 0 ~ size ) { 116 121 sout  sarr[i]  ", "; 117 122 } // for 118 123 sout  nl; 119 for ( i; 0 u~ size ) {124 for ( i; 0 ~ size ) { 120 125 S temp = { size  i, size  i + 1 }; 121 126 S * v = bsearch( temp, sarr, size ); … … 123 128 } // for 124 129 sout  nl; 125 for ( i; 0 u~ size ) {130 for ( i; 0 ~ size ) { 126 131 S temp = { size  i, size  i + 1 }; 127 132 unsigned int posn = bsearch( temp, sarr, size ); … … 130 135 sout  nl; 131 136 { 132 unsignedint getKey( const S & s ) { return s.j; }133 for ( i; 0 u~ size ) {137 int getKey( const S & s ) { return s.j; } 138 for ( i; 0 ~ size ) { 134 139 sout  sarr[i]  ", "; 135 140 } // for 136 141 sout  nl; 137 for ( i; 0 u~ size ) {142 for ( i; 0 ~ size ) { 138 143 S * v = bsearch( size  i + 1, sarr, size ); 139 144 sout  size  i + 1  ':'  *v  ", "; 140 145 } // for 141 146 sout  nl; 142 for ( i; 0 u~ size ) {147 for ( i; 0 ~ size ) { 143 148 unsigned int posn = bsearch( size  i + 1, sarr, size ); 144 149 sout  size  i + 1  ':'  sarr[posn]  ", ";
Note: See TracChangeset
for help on using the changeset viewer.