com.jme3.util
Class SortUtil

java.lang.Object
  extended by com.jme3.util.SortUtil

public class SortUtil
extends java.lang.Object

Quick and merge sort implementations that create no garbage, unlike Arrays.sort(long[]). The merge sort is stable, the quick sort is not.


Constructor Summary
SortUtil()
           
 
Method Summary
static void gsort(java.lang.Object[] a, java.util.Comparator comp)
          procedure optimizedGnomeSort(a[]) pos := 1 last := 0 while pos < length(a) if (a[pos] >= a[pos-1]) if (last != 0) pos := last last := 0 end if pos := pos + 1 else swap a[pos] and a[pos-1] if (pos > 1) if (last == 0) last := pos end if pos := pos - 1 else pos := pos + 1 end if end if end while end procedure
static void main(java.lang.String[] args)
           
static void msort(java.lang.Object[] src, java.lang.Object[] dest, java.util.Comparator comp)
          Merge sort
static void msort(java.lang.Object[] src, java.lang.Object[] dest, int low, int high, java.util.Comparator comp)
          Merge sort
static void qsort(int[] a, int lo0, int hi0, java.util.Comparator comp)
           
static void qsort(java.lang.Object[] a, java.util.Comparator comp)
          Quick sorts the supplied array using the specified comparator.
static void qsort(java.lang.Object[] a, int lo0, int hi0, java.util.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
 

Constructor Detail

SortUtil

public SortUtil()
Method Detail

gsort

public static void gsort(java.lang.Object[] a,
                         java.util.Comparator comp)
procedure optimizedGnomeSort(a[]) pos := 1 last := 0 while pos < length(a) if (a[pos] >= a[pos-1]) if (last != 0) pos := last last := 0 end if pos := pos + 1 else swap a[pos] and a[pos-1] if (pos > 1) if (last == 0) last := pos end if pos := pos - 1 else pos := pos + 1 end if end if end while end procedure


main

public static void main(java.lang.String[] args)

qsort

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


qsort

public static void qsort(java.lang.Object[] a,
                         int lo0,
                         int hi0,
                         java.util.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,
                         java.util.Comparator comp)

msort

public static void msort(java.lang.Object[] src,
                         java.lang.Object[] dest,
                         java.util.Comparator comp)
Merge sort


msort

public static void msort(java.lang.Object[] src,
                         java.lang.Object[] dest,
                         int low,
                         int high,
                         java.util.Comparator comp)
Merge sort

Parameters:
src - Source array
dest - Destination array
low - Index of beginning element
high - Index of end element
comp - Comparator