# HG changeset patch # User Shinji KONO # Date 1364386418 -32400 # Node ID 665ccc899b3b09776917b68a7e74c4faf021562a # Parent b8f72b378f18503389131b2656fc20e228aa4022 fix merge diff -r b8f72b378f18 -r 665ccc899b3b src/alice/test/codesegment/local/bitonicsort/DataList.java --- a/src/alice/test/codesegment/local/bitonicsort/DataList.java Wed Mar 27 16:39:51 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/DataList.java Wed Mar 27 21:13:38 2013 +0900 @@ -40,19 +40,28 @@ public static void merge(DataList list1, DataList list2) { int[] t1 = list1.table; int[] t2 = list2.table; - int i = 0, j= 0; - while (i< t1.length){ - if (t1[i] < t2[j]) { - i++; - } else { - int tmp = t1[i]; - t1[i] = t2[j]; - t2[j] = tmp; - j++; - } - - } - + int[] t0 = list1.table.clone(); + int i = 0, j= 0,n=0; + while (i< t0.length && n=t2.length || t0[i] < t2[j]) { + t1[n] = t0[i]; + i++; n++; + } else { + t1[n] = t2[j]; + j++; n++; + } + } + while (i< t0.length && n=t2.length || t0[i] < t2[j]) { + t2[n-t1.length] = t0[i]; + i++; n++; + } else { + t2[n-t1.length] = t2[j]; + j++; n++; + } + } + + } }