SortUtil: I]E 3&gnC
I7~) q`
package org.rut.util.algorithm; _TGs .t
*3rs+0
import org.rut.util.algorithm.support.BubbleSort; ft$RF
import org.rut.util.algorithm.support.HeapSort; |`t 6lVO,Z
import org.rut.util.algorithm.support.ImprovedMergeSort; X%3?sH
import org.rut.util.algorithm.support.ImprovedQuickSort; H!&_Tv[
import org.rut.util.algorithm.support.InsertSort; Tjhy@3
import org.rut.util.algorithm.support.MergeSort; cR_ pC
9z
import org.rut.util.algorithm.support.QuickSort; D}LM(s3li7
import org.rut.util.algorithm.support.SelectionSort; OF+4Mq
import org.rut.util.algorithm.support.ShellSort; n\3#69VY
J=t}9.H~=
/** }ML2-k
* @author treeroot q\~
#g.}
* @since 2006-2-2 -z0;4O (K]
* @version 1.0 G}9f/$'3
*/ c!/+0[
public class SortUtil { X6r0+D5AvB
public final static int INSERT = 1; !ltq@8#_|
public final static int BUBBLE = 2; fBj)HoHQW
public final static int SELECTION = 3; >36,lNt
public final static int SHELL = 4; X;N?L%Pp
public final static int QUICK = 5; ^'0N%`bY!
public final static int IMPROVED_QUICK = 6; hlB\Xt
public final static int MERGE = 7; (+[%^96
public final static int IMPROVED_MERGE = 8; xcU!bDV
public final static int HEAP = 9; 7J!s"|VS
W(R~K -
public static void sort(int[] data) { %l!?d`?
sort(data, IMPROVED_QUICK); {
]_j)R
} L*tfYonq
private static String[] name={ w2'q9pB+
"insert", "bubble", "selection", "shell", "quick", "improved_quick", "merge", "improved_merge", "heap" >ItT269G
}; )38%E;T{X
(u} /(Ux
private static Sort[] impl=new Sort[]{ ]i@73h YT
new InsertSort(), oV0T
new BubbleSort(), 9K/EteS
new SelectionSort(), 2Y23!hw
new ShellSort(), 5dI=;L>D
new QuickSort(), J\Pb/9M/
new ImprovedQuickSort(), xdgAu
new MergeSort(), <Q\KS
new ImprovedMergeSort(), vxj:Y'}
new HeapSort() h_[{-WC
}; VMRfDaO9
!>n!Q*\(Ov
public static String toString(int algorithm){ b4i=%]v8
return name[algorithm-1]; XPO-u]<