Package com.jme3.util

Class SortUtil

java.lang.Object
com.jme3.util.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.
  • Constructor Details

    • SortUtil

      public SortUtil()
  • Method Details

    • gsort

      public static void gsort(Object[] a, Comparator comp)
    • main

      public static void main(String[] args)
    • qsort

      public static void qsort(Object[] a, Comparator comp)
      Quick sorts the supplied array using the specified comparator.
      Parameters:
      a - the array to sort (not null, modified)
      comp - the Comparator to use (not null)
    • qsort

      public static void qsort(Object[] a, int lo0, int hi0, Comparator comp)
      Quick sorts the supplied array using the specified comparator.
      Parameters:
      a - the array to sort (modified)
      lo0 - the index of the lowest element to include in the sort.
      hi0 - the index of the highest element to include in the sort.
      comp - the Comparator to use (not null)
    • 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 sort
      Parameters:
      src - the source array (not null)
      dest - the destination array (not null)
      comp - the Comparator to use
    • msort

      public static void msort(Object[] src, Object[] dest, int low, int high, Comparator comp)
      Merge sort
      Parameters:
      src - Source array
      dest - Destination array
      low - Index of beginning element
      high - Index of end element
      comp - Comparator