@@ -0,0 +1,2057 @@
+package org.tanc.algorithm.sort.impl;%0A%0Aimport org.tanc.algorithm.sort.BaseSortAlgorithm;%0A%0A/**%0A * %E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F%0A * Created by tanc on 2017/2/16.%0A */%0Apublic class QuickSort%3CE extends Comparable%3C? super E%3E%3E implements BaseSortAlgorithm%3CE%3E %7B%0A%0A    private InsertionSort%3CE%3E insertSort;%0A%0A    public QuickSort() %7B%0A        insertSort = new InsertionSort%3C%3E();%0A    %7D%0A%0A    @Override%0A    public E%5B%5D sort(E%5B%5D array) %7B%0A%0A        sort(array, 0, array.length - 1);%0A%0A        return array;%0A    %7D%0A%0A    private void sort(E%5B%5D a, int left, int right) %7B%0A%0A        int length = right - left + 1;%0A%0A        if (length %3C= 3) %7B%0A            // %E4%B8%8D%E5%A4%9A%E4%BA%8E%E4%B8%89%E4%B8%AA%E5%85%83%E7%B4%A0%E7%9A%84%E6%95%B0%E7%BB%84%E4%BD%BF%E7%94%A8%E6%8F%92%E5%85%A5%E6%8E%92%E5%BA%8F%0A            insertSort.sort(a, left, right);%0A            return;%0A        %7D%0A%0A        int center = (left + right) / 2;%0A        int first = left;%0A        int last = right;%0A%0A        update3Elements(a, left, center, right);%0A%0A        E temp = a%5Bright - 1%5D;%0A        a%5Bright - 1%5D = a%5Bright%5D;%0A        a%5Bright%5D = a%5Bcenter%5D;%0A        a%5Bcenter%5D = temp;%0A%0A        right = right - 2;%0A        left = left + 1;%0A%0A        while (true) %7B%0A            while (a%5Bleft%5D.compareTo(a%5Blast%5D) %3C= 0) %7B%0A                left++;%0A            %7D%0A            while (a%5Bright%5D.compareTo(a%5Blast%5D) %3E= 0) %7B%0A                right--;%0A            %7D%0A            if (left %3C right) %7B%0A                temp = a%5Bleft%5D;%0A                a%5Bleft%5D = a%5Bright%5D;%0A                a%5Bright%5D = temp;%0A            %7D else %7B%0A                break;%0A            %7D%0A        %7D%0A%0A        temp = a%5Blast%5D;%0A        a%5Blast%5D = a%5Bleft%5D;%0A        a%5Bleft%5D = temp;%0A%0A        sort(a, first, left - 1);%0A        sort(a, left + 1, last);%0A    %7D%0A%0A    private void swap(E%5B%5D a, int b, int c) %7B%0A        E temp = a%5Bb%5D;%0A        a%5Bb%5D = a%5Bc%5D;%0A        a%5Bc%5D = temp;%0A    %7D%0A%0A    private void update3Elements(E%5B%5D a, int left, int center, int right) %7B%0A        if (a%5Bleft%5D.compareTo(a%5Bcenter%5D) %3E= 0) %7B%0A            swap(a, left, center);%0A        %7D%0A        if (a%5Bleft%5D.compareTo(a%5Bright%5D) %3E= 0) %7B%0A            swap(a, left, right);%0A        %7D%0A        if (a%5Bcenter%5D.compareTo(a%5Bright%5D) %3E= 0) %7B%0A            swap(a, center, right);%0A        %7D%0A    %7D%0A%7D%0A

add quick sort files