Class Sort


  • public class Sort
    extends java.lang.Object
    Provides methods to sort arrays of objects. Sorting requires working memory and this class allows that memory to be reused to avoid allocation. The sorting is otherwise identical to the Arrays.sort methods (uses timsort).

    Note that sorting primitive arrays with the Arrays.sort methods does not allocate memory (unless sorting large arrays of char, short, or byte).
    • Constructor Summary

      Constructors 
      Constructor Description
      Sort()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Sort instance()
      Returns a Sort instance for convenience.
      <T extends java.lang.Comparable>
      void
      sort​(Array<T> a)  
      <T> void sort​(Array<T> a, java.util.Comparator<? super T> c)  
      void sort​(java.lang.Object[] a)
      The specified objects must implement Comparable.
      void sort​(java.lang.Object[] a, int fromIndex, int toIndex)
      The specified objects must implement Comparable.
      <T> void sort​(T[] a, java.util.Comparator<? super T> c)  
      <T> void sort​(T[] a, java.util.Comparator<? super T> c, int fromIndex, int toIndex)  
      • Methods inherited from class java.lang.Object

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

      • Sort

        public Sort()
    • Method Detail

      • sort

        public <T extends java.lang.Comparable> void sort​(Array<T> a)
      • sort

        public void sort​(java.lang.Object[] a)
        The specified objects must implement Comparable.
      • sort

        public void sort​(java.lang.Object[] a,
                         int fromIndex,
                         int toIndex)
        The specified objects must implement Comparable.
      • sort

        public <T> void sort​(Array<T> a,
                             java.util.Comparator<? super T> c)
      • sort

        public <T> void sort​(T[] a,
                             java.util.Comparator<? super T> c)
      • sort

        public <T> void sort​(T[] a,
                             java.util.Comparator<? super T> c,
                             int fromIndex,
                             int toIndex)
      • instance

        public static Sort instance()
        Returns a Sort instance for convenience. Multiple threads must not use this instance at the same time.