Class QuickSort


  • public final class QuickSort
    extends java.lang.Object
    see http://de.wikipedia.org/wiki/Quicksort.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Comparator<? extends java.lang.Comparable> OBJCOMP  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private QuickSort()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> int partition​(java.util.List<T> list, java.util.Comparator<T> cmp, int p, int start, int end)  
      private static <T> void quicksort​(java.util.List<T> list, java.util.Comparator<T> cmp)  
      static <T extends java.lang.Comparable>
      void
      sort​(java.util.List<T> list)
      Sorts the given list using compareTo as comparator.
      static <T> void sort​(java.util.List<T> list, java.util.Comparator<T> cmp)
      Sorts the given list using the given comparator.
      private static <T> void swap​(java.util.List<T> list, int i, int j)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OBJCOMP

        private static final java.util.Comparator<? extends java.lang.Comparable> OBJCOMP
    • Constructor Detail

      • QuickSort

        private QuickSort()
    • Method Detail

      • sort

        public static <T> void sort​(java.util.List<T> list,
                                    java.util.Comparator<T> cmp)
        Sorts the given list using the given comparator.
        Type Parameters:
        T - type of the objects to be sorted.
        Parameters:
        list - list to be sorted
        cmp - comparator used to compare the objects within the list
      • sort

        public static <T extends java.lang.Comparable> void sort​(java.util.List<T> list)
        Sorts the given list using compareTo as comparator.
        Type Parameters:
        T - type of the objects to be sorted.
        Parameters:
        list - list to be sorted
      • quicksort

        private static <T> void quicksort​(java.util.List<T> list,
                                          java.util.Comparator<T> cmp)
      • partition

        private static <T> int partition​(java.util.List<T> list,
                                         java.util.Comparator<T> cmp,
                                         int p,
                                         int start,
                                         int end)
      • swap

        private static <T> void swap​(java.util.List<T> list,
                                     int i,
                                     int j)