|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.amino.alg.sort.AbstractSorter
org.amino.alg.sort.DefaultSorter
org.amino.alg.sort.QuickSorter
public class QuickSorter
This class implements the basic sequential quicksort algorithm. Provides functions to sort in both ascending and descending order.
| Field Summary | |
|---|---|
protected Sorter |
is
Insert sorter. |
protected static int |
IS_THRESHOLD
Threshold if used to decide if quick sort is needed. |
| Constructor Summary | |
|---|---|
QuickSorter()
|
|
| Method Summary | |
|---|---|
protected static int |
median(byte[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(char[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(double[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(float[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(int[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(long[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
median(short[] data,
int ax,
int bx,
int cx)
Routine to find pivot element. |
protected static int |
ninther(int[] data,
int first,
int mid,
int last)
Routine to find pivot element. |
void |
reverse(byte[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(char[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(double[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(float[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(int[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(long[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
void |
reverse(short[] a,
int from,
int to)
Sort array using reverse natural (descending) order. |
protected int |
selectPivot(byte[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(char[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(double[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(float[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(int[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(long[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
protected int |
selectPivot(short[] a,
int fromIndex,
int toIndex)
Select a pivot element from the given array section. |
void |
sort(byte[] a,
int from,
int to)
|
void |
sort(char[] a,
int from,
int to)
|
void |
sort(double[] a,
int from,
int to)
|
void |
sort(float[] a,
int from,
int to)
|
void |
sort(int[] a,
int from,
int to)
|
void |
sort(long[] a,
int from,
int to)
|
void |
sort(short[] a,
int from,
int to)
|
| Methods inherited from class org.amino.alg.sort.DefaultSorter |
|---|
reverse, reverse, sort, sort, sort, sort, sort, sort, sortp |
| Methods inherited from class org.amino.alg.sort.AbstractSorter |
|---|
reverse, reverse, reverse, reverse, reverse, reverse, reverse, reverse, reverse, sort, sort, sort, sort, sort, sort, sort, sort, sort, swap, swap, swap, swap, swap, swap, swap, swap, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfGreater, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess, swapIfLess |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int IS_THRESHOLD
protected Sorter is
| Constructor Detail |
|---|
public QuickSorter()
| Method Detail |
|---|
protected static int median(byte[] data,
int ax,
int bx,
int cx)
data - is byte array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(char[] data,
int ax,
int bx,
int cx)
data - is charater array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(short[] data,
int ax,
int bx,
int cx)
data - is short array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(int[] data,
int ax,
int bx,
int cx)
data - is int array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(long[] data,
int ax,
int bx,
int cx)
data - is long array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(float[] data,
int ax,
int bx,
int cx)
data - is float array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int median(double[] data,
int ax,
int bx,
int cx)
data - is double array to be sortedax - is the first indexbx - is the mid indexcx - is the last index
protected static int ninther(int[] data,
int first,
int mid,
int last)
data - is int array to be sortedfirst - is the first indexmid - is the mid indexlast - is the last index
protected int selectPivot(int[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(byte[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(char[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(short[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(long[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(float[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
protected int selectPivot(double[] a,
int fromIndex,
int toIndex)
a - the array to be sortedfromIndex - the index of the first element (inclusive) to be sortedtoIndex - the index of the last element (exclusive) to be sorted
public void sort(byte[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the byte array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(byte[], int, int)
public void sort(char[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the character array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(byte[], int, int)
public void sort(short[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the short array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(short[], int, int)
public void sort(int[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the int array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(short[], int, int)
public void sort(long[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the long array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(short[], int, int)
public void sort(float[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the float array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(short[], int, int)
public void sort(double[] a,
int from,
int to)
sort in interface Sortersort in class DefaultSortera - is the double array to be sorted in an ascending orderfrom - is the start index of array to be sortedto - is the end index of array to be sortedArrays.sort(short[], int, int)
public void reverse(byte[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the byte array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(char[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the character array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(short[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the short array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(int[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the int array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(long[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the long array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(float[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the float array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
public void reverse(double[] a,
int from,
int to)
reverse in interface Sorterreverse in class DefaultSortera - is the double array to be sorted in a descending orderfrom - is the start index of array to be sortedto - is the end index of array to be sorted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||