Changeset 3ac5fd8 for tests/concurrency
- Timestamp:
- Aug 17, 2024, 3:15:21 PM (4 months ago)
- Branches:
- master
- Children:
- df2e00f
- Parents:
- afb15cf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/examples/quickSort.cfa
rafb15cf r3ac5fd8 11 11 // Created On : Wed Dec 6 12:15:52 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Mon Jan 1 12:07:59202414 // Update Count : 1 8813 // Last Modified On : Sat Aug 17 13:59:15 2024 14 // Update Count : 199 15 15 // 16 16 … … 145 145 146 146 if ( size == -1 ) { // generate output ? 147 for () { 148 unsortedfile | size; // read number of elements in the list 149 if ( eof( unsortedfile ) ) break; 150 151 int * values = aalloc( size ); // values to be sorted, too large to put on stack 152 for ( counter; size ) { // read unsorted numbers 153 unsortedfile | values[counter]; 154 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 155 sortedfile | values[counter]; 156 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 147 int * values = 0p; 148 try { 149 for () { 150 unsortedfile | size; // read number of elements in the list 151 values = aalloc( size ); // values to be sorted, too large to put on stack 152 for ( counter; size ) { // read unsorted numbers 153 unsortedfile | values[counter]; 154 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 155 sortedfile | values[counter]; 156 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 157 } // for 158 sortedfile | nl; 159 160 if ( size > 0 ) { // values to sort ? 161 Quicksort QS = { values, size - 1, 0 }; // sort values 162 } // wait until sort tasks terminate 163 for ( counter; size ) { // print sorted list 164 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 165 sortedfile | values[counter]; 166 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 167 } // for 168 sortedfile | nl | nl; 169 170 delete( values ); 171 values = 0p; 157 172 } // for 158 sortedfile | nl; 159 160 if ( size > 0 ) { // values to sort ? 161 Quicksort QS = { values, size - 1, 0 }; // sort values 162 } // wait until sort tasks terminate 163 for ( counter; size ) { // print sorted list 164 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 165 sortedfile | values[counter]; 166 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 167 } // for 168 sortedfile | nl | nl; 169 173 } catch( end_of_file * ) { 170 174 delete( values ); 171 } // for175 } // try 172 176 } else { // timing 173 177 PRNG prng;
Note: See TracChangeset
for help on using the changeset viewer.