/** * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. */ private static void vecswap(Swapper swapper, int a, int b, int n) { for (int i=0; i<n; i++, a++, b++) swapper.swap(a, b); } }
/** * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. */ private static void vecswap(Swapper swapper, int a, int b, int n) { for (int i = 0; i < n; i++, a++, b++) swapper.swap(a, b); } }
/** * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. */ private static void vecswap(Swapper swapper, int a, int b, int n) { for (int i = 0; i < n; i++, a++, b++) swapper.swap(a, b); } }
/** * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. */ private static void vecswap(Swapper swapper, int a, int b, int n) { for (int i=0; i<n; i++, a++, b++) swapper.swap(a, b); } }
/** * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. */ private static void vecswap(Swapper swapper, int a, int b, int n) { for (int i = 0; i < n; i++, a++, b++) swapper.swap(a, b); } }
/** * Reverses a sequence of elements. * @param array Array containing the sequence * @param first Beginning of the range * @param last One past the end of the range * @exception ArrayIndexOutOfBoundsException If the range * is invalid. */ private static void reverse(int first, int last, Swapper swapper) { // no more needed since manually inlined while (first < --last) { swapper.swap(first++,last); } } /**
/** * Reverses a sequence of elements. * @param array Array containing the sequence * @param first Beginning of the range * @param last One past the end of the range * @exception ArrayIndexOutOfBoundsException If the range * is invalid. */ private static void reverse(int first, int last, Swapper swapper) { // no more needed since manually inlined while (first < --last) { swapper.swap(first++,last); } } /**
/** * Reverses a sequence of elements. * * @param array * Array containing the sequence * @param first * Beginning of the range * @param last * One past the end of the range * @exception ArrayIndexOutOfBoundsException * If the range is invalid. */ private static void reverse(int first, int last, Swapper swapper) { // no more needed since manually inlined while (first < --last) { swapper.swap(first++, last); } }
/** * Reverses a sequence of elements. * * @param array * Array containing the sequence * @param first * Beginning of the range * @param last * One past the end of the range * @exception ArrayIndexOutOfBoundsException * If the range is invalid. */ private static void reverse(int first, int last, Swapper swapper) { // no more needed since manually inlined while (first < --last) { swapper.swap(first++, last); } }
/** * Reverses a sequence of elements. * * @param array * Array containing the sequence * @param first * Beginning of the range * @param last * One past the end of the range * @exception ArrayIndexOutOfBoundsException * If the range is invalid. */ private static void reverse(int first, int last, Swapper swapper) { // no more needed since manually inlined while (first < --last) { swapper.swap(first++, last); } }
swapper.swap(i,track); tracks[index]=i; tracks[pos[i]]=track; int tmp = pos[i]; pos[i]=pos[track]; pos[track]=tmp;
/** * Same as {@link #partition(int[],int,int,int)} except that it * <i>generically</i> partitions arbitrary shaped data (for example matrices * or multiple arrays) rather than <tt>int[]</tt> arrays. */ private static int genericPartition(int from, int to, int splitter, IntComparator comp, Swapper swapper) { for (int i = from - 1; ++i <= to;) { if (comp.compare(splitter, i) > 0) { // swap x[i] with x[from] swapper.swap(i, from); from++; } } return from - 1; }
/** Same as {@link #partition(int[],int,int,int)} except that it <i>generically</i> partitions arbitrary shaped data (for example matrices or multiple arrays) rather than <tt>int[]</tt> arrays. */ private static int genericPartition(int from, int to, int splitter, IntComparator comp, Swapper swapper) { for (int i=from-1; ++i<=to; ) { if (comp.compare(splitter,i) > 0) { // swap x[i] with x[from] swapper.swap(i,from); from++; } } return from-1; } /**
/** Same as {@link #partition(int[],int,int,int)} except that it <i>generically</i> partitions arbitrary shaped data (for example matrices or multiple arrays) rather than <tt>int[]</tt> arrays. */ private static int genericPartition(int from, int to, int splitter, IntComparator comp, Swapper swapper) { for (int i=from-1; ++i<=to; ) { if (comp.compare(splitter,i) > 0) { // swap x[i] with x[from] swapper.swap(i,from); from++; } } return from-1; } /**
/** * Same as {@link #partition(int[],int,int,int)} except that it * <i>generically</i> partitions arbitrary shaped data (for example matrices * or multiple arrays) rather than <tt>int[]</tt> arrays. */ private static int genericPartition(int from, int to, int splitter, IntComparator comp, Swapper swapper) { for (int i = from - 1; ++i <= to;) { if (comp.compare(splitter, i) > 0) { // swap x[i] with x[from] swapper.swap(i, from); from++; } } return from - 1; }
if (last - first == 2) { if (comp.compare(middle, first)<0) { swapper.swap(first,middle); if (middle2 != first2 && middle2 != last2) { int first1 = first2; int last1 = middle2; while (first1 < --last1) swapper.swap(first1++,last1); first1 = middle2; last1 = last2; while (first1 < --last1) swapper.swap(first1++,last1); first1 = first2; last1 = last2; while (first1 < --last1) swapper.swap(first1++,last1);
if (last - first == 2) { if (comp.compare(middle, first) < 0) { swapper.swap(first, middle); int last1 = middle2; while (first1 < --last1) swapper.swap(first1++, last1); first1 = middle2; last1 = last2; while (first1 < --last1) swapper.swap(first1++, last1); first1 = first2; last1 = last2; while (first1 < --last1) swapper.swap(first1++, last1);
if (last - first == 2) { if (comp.compare(middle, first)<0) { swapper.swap(first,middle); if (middle2 != first2 && middle2 != last2) { int first1 = first2; int last1 = middle2; while (first1 < --last1) swapper.swap(first1++,last1); first1 = middle2; last1 = last2; while (first1 < --last1) swapper.swap(first1++,last1); first1 = first2; last1 = last2; while (first1 < --last1) swapper.swap(first1++,last1);
for (int i = fromIndex; i < toIndex; i++) { for (int j = i; j > fromIndex && (c.compare(j - 1, j) > 0); j--) { swapper.swap(j, j - 1);
for (int i = fromIndex; i < toIndex; i++) { for (int j = i; j > fromIndex && (c.compare(j - 1, j) > 0); j--) { swapper.swap(j, j - 1);