Class Sorter<T>

  • Direct Known Subclasses:
    Sorter.QuickSorter

    public abstract class Sorter<T>
    extends java.lang.Object
    This class performs merge sort over an array but allocates the additional array used in merge sort upfront so if the arrays of same size will be sorted repeatedly this sorter can be reused to minimize garbage collection with the price of having memory for extra array always being used.
    Author:
    Evren Sirin
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Sorter.QuickSorter<T>
      Sorter implementation for QuickSort.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Comparator<? super T> c  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Sorter​(java.util.Comparator<? super T> c)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Sorter<T> create​(int length, java.util.Comparator<? super T> comp)  
      abstract void sort​(T[] array, int start, int end)  
      • Methods inherited from class java.lang.Object

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

      • c

        protected final java.util.Comparator<? super T> c
    • Constructor Detail

      • Sorter

        protected Sorter​(java.util.Comparator<? super T> c)
    • Method Detail

      • create

        public static <T> Sorter<T> create​(int length,
                                           java.util.Comparator<? super T> comp)
      • sort

        public abstract void sort​(T[] array,
                                  int start,
                                  int end)