Changeset 8f34661 for src/tests/searchsort.c
- Timestamp:
- Aug 9, 2018, 9:20:15 PM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- b7c55277
- Parents:
- 3b2b37f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/searchsort.c
r3b2b37f r8f34661 10 10 // Created On : Thu Feb 4 18:17:50 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 2 08:01:17 201813 // Update Count : 10 012 // Last Modified On : Thu Aug 9 07:54:57 2018 13 // Update Count : 101 14 14 // 15 15 … … 24 24 int iarr[size]; 25 25 26 for ( unsigned int i = 0; i < size; i += 1) {26 for ( i; 0u ~ size ) { 27 27 iarr[i] = size - i; 28 28 sout | iarr[i] | ", "; … … 32 32 // ascending sort/search by changing < to > 33 33 qsort( iarr, size ); 34 for ( unsigned int i = 0; i < size; i += 1) {34 for ( i; 0u ~ size ) { 35 35 sout | iarr[i] | ", "; 36 36 } // for 37 37 sout | endl; 38 for ( unsigned int i = 0; i < size; i += 1) { // C version38 for ( i; 0u ~ size ) { // C version 39 39 int key = size - i; 40 40 int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp ); … … 43 43 sout | endl; 44 44 45 for ( unsigned int i = 0; i < size; i += 1) {45 for ( i; 0u ~ size ) { 46 46 int * v = bsearch( size - i, iarr, size ); 47 47 sout | size - i | ':' | *v | ", "; 48 48 } // for 49 49 sout | endl; 50 for ( unsigned int i = 0; i < size; i += 1) {50 for ( i; 0u ~ size ) { 51 51 unsigned int posn = bsearch( size - i, iarr, size ); 52 52 sout | size - i | ':' | iarr[posn] | ", "; … … 55 55 56 56 // descending sort/search by changing < to > 57 for ( unsigned int i = 0; i < size; i += 1) {57 for ( i; 0u ~ size ) { 58 58 iarr[i] = i + 1; 59 59 sout | iarr[i] | ", "; … … 63 63 int ?<?( int x, int y ) { return x > y; } 64 64 qsort( iarr, size ); 65 for ( unsigned int i = 0; i < size; i += 1) {65 for ( i; 0u ~ size ) { 66 66 sout | iarr[i] | ", "; 67 67 } // for 68 68 sout | endl; 69 for ( unsigned int i = 0; i < size; i += 1) {69 for ( i; 0u ~ size ) { 70 70 int * v = bsearch( size - i, iarr, size ); 71 71 sout | size - i | ':' | *v | ", "; 72 72 } // for 73 73 sout | endl; 74 for ( unsigned int i = 0; i < size; i += 1) {74 for ( i; 0u ~ size ) { 75 75 unsigned int posn = bsearch( size - i, iarr, size ); 76 76 sout | size - i | ':' | iarr[posn] | ", "; … … 80 80 81 81 double darr[size]; 82 for ( unsigned int i = 0; i < size; i += 1) {82 for ( i; 0u ~ size ) { 83 83 darr[i] = size - i + 0.5; 84 84 sout | darr[i] | ", "; … … 86 86 sout | endl; 87 87 qsort( darr, size ); 88 for ( unsigned int i = 0; i < size; i += 1) {88 for ( i; 0u ~ size ) { 89 89 sout | darr[i] | ", "; 90 90 } // for 91 91 sout | endl; 92 for ( unsigned int i = 0; i < size; i += 1) {92 for ( i; 0u ~ size ) { 93 93 double * v = bsearch( size - i + 0.5, darr, size ); 94 94 sout | size - i + 0.5 | ':' | *v | ", "; 95 95 } // for 96 96 sout | endl; 97 for ( unsigned int i = 0; i < size; i += 1) {97 for ( i; 0u ~ size ) { 98 98 unsigned int posn = bsearch( size - i + 0.5, darr, size ); 99 99 sout | size - i + 0.5 | ':' | darr[posn] | ", "; … … 104 104 int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; } 105 105 ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; } 106 for ( unsigned int i = 0; i < size; i += 1) {106 for ( i; 0u ~ size ) { 107 107 sarr[i].i = size - i; 108 108 sarr[i].j = size - i + 1; … … 111 111 sout | endl; 112 112 qsort( sarr, size ); 113 for ( unsigned int i = 0; i < size; i += 1) {113 for ( i; 0u ~ size ) { 114 114 sout | sarr[i] | ", "; 115 115 } // for 116 116 sout | endl; 117 for ( unsigned int i = 0; i < size; i += 1) {117 for ( i; 0u ~ size ) { 118 118 S temp = { size - i, size - i + 1 }; 119 119 S * v = bsearch( temp, sarr, size ); … … 121 121 } // for 122 122 sout | endl; 123 for ( unsigned int i = 0; i < size; i += 1) {123 for ( i; 0u ~ size ) { 124 124 S temp = { size - i, size - i + 1 }; 125 125 unsigned int posn = bsearch( temp, sarr, size ); … … 129 129 { 130 130 unsigned int getKey( const S & s ) { return s.j; } 131 for ( unsigned int i = 0; i < size; i += 1) {131 for ( i; 0u ~ size ) { 132 132 sout | sarr[i] | ", "; 133 133 } // for 134 134 sout | endl; 135 for ( unsigned int i = 0; i < size; i += 1) {135 for ( i; 0u ~ size ) { 136 136 S * v = bsearch( size - i + 1, sarr, size ); 137 137 sout | size - i + 1 | ':' | *v | ", "; 138 138 } // for 139 139 sout | endl; 140 for ( unsigned int i = 0; i < size; i += 1) {140 for ( i; 0u ~ size ) { 141 141 unsigned int posn = bsearch( size - i + 1, sarr, size ); 142 142 sout | size - i + 1 | ':' | sarr[posn] | ", ";
Note: See TracChangeset
for help on using the changeset viewer.