From: adash Date: Mon, 19 Nov 2007 23:11:29 +0000 (+0000) Subject: Test file for prefetch X-Git-Tag: preEdgeChange~358 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9ce4045e4173057dd128a6aa054c70c9f3362763;p=IRC.git Test file for prefetch --- diff --git a/Robust/src/Tests/Prefetch/QuickSort.java b/Robust/src/Tests/Prefetch/QuickSort.java new file mode 100644 index 00000000..fd34b344 --- /dev/null +++ b/Robust/src/Tests/Prefetch/QuickSort.java @@ -0,0 +1,82 @@ +public class QuickSort { + public QuickSort() { + } + + public void quick_srt(int array[],int low, int n){ + int lo = low; + int hi = n; + if (lo >= n) { + return; + } + int mid = array[(lo + hi) / 2]; + while (lo < hi) { + while (lo mid) { + hi--; + } + if (lo < hi) { + int T = array[lo]; + array[lo] = array[hi]; + array[hi] = T; + } + } + if (hi < lo) { + int T = hi; + hi = lo; + lo = T; + } + quick_srt(array, low, lo); + if(lo == low) { + low = lo+1; + } + else { + low = lo; + } + quick_srt(array, low, n); + } + + public static void main(String[] args) { + int i; + int j; + QArray myArray[] = new QArray[2]; + myArray[0] = new QArray(); + myArray[1] = new QArray(); + QuickSort qsort = new QuickSort(); + System.printString("Values Before sorting\n"); + for(i = 0; i<2; i++){ + for(j = 0; j<10; j++){ + System.printInt(myArray[i].mya[j]); + System.printString("\t"); + } + System.printString("\n"); + } + for(i = 0; i<2; i++){ + qsort.quick_srt(myArray[i].mya, 0, 9); + } + System.printString("Values After sorting\n"); + for(i = 0; i<2; i++){ + for(j = 0; j<10; j++){ + System.printInt(myArray[i].mya[j]); + System.printString("\t"); + } + System.printString("\n"); + } + System.printString("\n"); + } +} + +public class QArray { + public int mya[]; + public QArray() { + mya = new int[10]; + mya[0] = 65; + mya[1] = 26; + mya[2] = 5; + mya[3] = 49; + for(int i = 4; i<9; i++) + mya[i] = 10*i; + mya[9] = 72; + } +}