|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.util.SortUtil
public class SortUtil
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 |
---|
public SortUtil()
Method Detail |
---|
public static void gsort(java.lang.Object[] a, java.util.Comparator comp)
public static void main(java.lang.String[] args)
public static void qsort(java.lang.Object[] a, java.util.Comparator comp)
public static void qsort(java.lang.Object[] a, int lo0, int hi0, java.util.Comparator comp)
lo0
- the index of the lowest element to include in the sort.hi0
- the index of the highest element to include in the sort.public static void qsort(int[] a, int lo0, int hi0, java.util.Comparator comp)
public static void msort(java.lang.Object[] src, java.lang.Object[] dest, java.util.Comparator comp)
public static void msort(java.lang.Object[] src, java.lang.Object[] dest, int low, int high, java.util.Comparator comp)
src
- Source arraydest
- Destination arraylow
- Index of beginning elementhigh
- Index of end elementcomp
- Comparator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |