java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Poisson.Octree.SortUtil

public class SortUtil extends Object
Quick and merge sort implementations that create no garbage, unlike Arrays.sort(int[]). The merge sort is stable, the quick sort is not.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    The size at or below which we will use insertion sort because it's probably faster.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static void
    msort(Object[] src, Object[] dest, int low, int high, int offset, Comparator comp)
    Implements the actual merge sort.
    static void
    msort(Object[] src, Object[] dest, int low, int high, Comparator comp)
    Merge sorts the supplied array using the specified comparator.
    static void
    msort(Object[] src, Object[] dest, Comparator comp)
    Merge sorts the supplied array using the specified comparator.
    static void
    qsort(int[] a, int lo0, int hi0, Comparator comp)
     
    static void
    qsort(Object[] a, int lo0, int hi0, Comparator comp)
    Quick sorts the supplied array using the specified comparator.
    static void
    qsort(Object[] a, Comparator comp)
    Quick sorts the supplied array using the specified comparator.

    Methods inherited from class java.lang.Object

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

    • INSERTION_SORT_THRESHOLD

      private static final int INSERTION_SORT_THRESHOLD
      The size at or below which we will use insertion sort because it's probably faster.
      See Also:
  • Constructor Details

    • SortUtil

      public SortUtil()
  • Method Details

    • qsort

      public static void qsort(Object[] a, Comparator comp)
      Quick sorts the supplied array using the specified comparator.
    • qsort

      public static void qsort(Object[] a, int lo0, int hi0, Comparator comp)
      Quick sorts the supplied array using the specified comparator.
      Parameters:
      lo0 - the index of the lowest element to include in the sort.
      hi0 - the index of the highest element to include in the sort.
    • qsort

      public static void qsort(int[] a, int lo0, int hi0, Comparator comp)
    • msort

      public static void msort(Object[] src, Object[] dest, Comparator comp)
      Merge sorts the supplied array using the specified comparator.
      Parameters:
      src - contains the elements to be sorted.
      dest - must contain the same values as the src array.
    • msort

      public static void msort(Object[] src, Object[] dest, int low, int high, Comparator comp)
      Merge sorts the supplied array using the specified comparator.
      Parameters:
      src - contains the elements to be sorted.
      dest - must contain the same values as the src array.
    • msort

      protected static void msort(Object[] src, Object[] dest, int low, int high, int offset, Comparator comp)
      Implements the actual merge sort.