public class QuickSelect extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
QuickSelect.Adapter<T>
Adapter class to apply QuickSelect to arbitrary data structures.
|
Modifier and Type | Field and Description |
---|---|
static QuickSelect.Adapter<byte[]> |
BYTE_ADAPTER
Adapter for byte arrays.
|
static QuickSelect.Adapter<char[]> |
CHAR_ADAPTER
Adapter for char arrays.
|
static QuickSelect.Adapter<double[]> |
DOUBLE_ADAPTER
Adapter for double arrays.
|
static QuickSelect.Adapter<float[]> |
FLOAT_ADAPTER
Adapter for float arrays.
|
static QuickSelect.Adapter<int[]> |
INTEGER_ADAPTER
Adapter for integer arrays.
|
static QuickSelect.Adapter<long[]> |
LONG_ADAPTER
Adapter for long arrays.
|
static QuickSelect.Adapter<short[]> |
SHORT_ADAPTER
Adapter for short arrays.
|
private static int |
SMALL
For small arrays, use a simpler method:
|
Constructor and Description |
---|
QuickSelect() |
Modifier and Type | Method and Description |
---|---|
private static int |
bestPivot(int rank,
int m1,
int m2,
int m3,
int m4,
int m5)
Choose the best pivot for the given rank.
|
private static void |
insertionSort(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
int start,
int end,
DBIDArrayIter iter1,
DBIDArrayIter iter2)
Sort a small array using repetitive insertion sort.
|
private static void |
insertionSort(double[] data,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
private static <T> void |
insertionSort(List<T> data,
Comparator<? super T> comparator,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
private static <T extends Comparable<? super T>> |
insertionSort(List<T> data,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
private static void |
insertionSort(ModifiableDoubleDBIDList data,
int start,
int end,
DoubleDBIDListIter iter1,
DoubleDBIDListIter iter2)
Sort a small array using repetitive insertion sort.
|
private static <T extends Comparable<? super T>> |
insertionSort(T[] data,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
private static <T> void |
insertionSort(T data,
QuickSelect.Adapter<T> adapter,
int start,
int end)
Sort a small array using repetitive insertion sort.
|
static int |
median(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
median(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
median(double[] data)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
median(double[] data,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
median(List<? extends T> data)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T> T |
median(List<? extends T> data,
Comparator<? super T> comparator)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T> T |
median(List<? extends T> data,
Comparator<? super T> comparator,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
median(List<? extends T> data,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
median(ModifiableDoubleDBIDList data)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
median(ModifiableDoubleDBIDList data,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
median(T[] data)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
median(T[] data,
int begin,
int end)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
quantile(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
quantile(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
quantile(double[] data,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static double |
quantile(double[] data,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T> T |
quantile(List<? extends T> data,
Comparator<? super T> comparator,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T> T |
quantile(List<? extends T> data,
Comparator<? super T> comparator,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
quantile(List<? extends T> data,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
quantile(List<? extends T> data,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
quantile(ModifiableDoubleDBIDList data,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static int |
quantile(ModifiableDoubleDBIDList data,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
quantile(T[] data,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static <T extends Comparable<? super T>> |
quantile(T[] data,
int begin,
int end,
double quant)
Compute the median of an array efficiently using the QuickSelect method.
|
static void |
quickSelect(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static void |
quickSelect(ArrayModifiableDBIDs data,
Comparator<? super DBIDRef> comparator,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static double |
quickSelect(double[] data,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static double |
quickSelect(double[] data,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T> T |
quickSelect(List<? extends T> data,
Comparator<? super T> comparator,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T> void |
quickSelect(List<? extends T> data,
Comparator<? super T> comparator,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T extends Comparable<? super T>> |
quickSelect(List<? extends T> data,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T extends Comparable<? super T>> |
quickSelect(List<? extends T> data,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static void |
quickSelect(ModifiableDoubleDBIDList data,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static void |
quickSelect(ModifiableDoubleDBIDList data,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T extends Comparable<? super T>> |
quickSelect(T[] data,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T extends Comparable<? super T>> |
quickSelect(T[] data,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
static <T> void |
quickSelect(T data,
QuickSelect.Adapter<T> adapter,
int start,
int end,
int rank)
QuickSelect is essentially quicksort, except that we only "sort" that half
of the array that we are interested in.
|
private static void |
swap(double[] data,
int a,
int b)
The usual swap method.
|
private static <T> void |
swap(List<T> data,
int a,
int b)
The usual swap method.
|
private static <T extends Comparable<? super T>> |
swap(T[] data,
int a,
int b)
The usual swap method.
|
private static final int SMALL
public static QuickSelect.Adapter<double[]> DOUBLE_ADAPTER
public static QuickSelect.Adapter<int[]> INTEGER_ADAPTER
public static QuickSelect.Adapter<float[]> FLOAT_ADAPTER
public static QuickSelect.Adapter<short[]> SHORT_ADAPTER
public static QuickSelect.Adapter<long[]> LONG_ADAPTER
public static QuickSelect.Adapter<byte[]> BYTE_ADAPTER
public static QuickSelect.Adapter<char[]> CHAR_ADAPTER
private static final int bestPivot(int rank, int m1, int m2, int m3, int m4, int m5)
rank
- Rankm1
- Pivot candidatem2
- Pivot candidatem3
- Pivot candidatem4
- Pivot candidatem5
- Pivot candidatepublic static <T> void quickSelect(T data, QuickSelect.Adapter<T> adapter, int start, int end, int rank)
data
- Data to processstart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static <T> void insertionSort(T data, QuickSelect.Adapter<T> adapter, int start, int end)
data
- Data to sortstart
- Interval startend
- Interval endpublic static double quickSelect(double[] data, int rank)
data
- Data to processrank
- Rank position that we are interested in (integer!)public static double median(double[] data)
data
- Data to processpublic static double median(double[] data, int begin, int end)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static double quantile(double[] data, double quant)
data
- Data to processquant
- Quantile to computepublic static double quantile(double[] data, int begin, int end, double quant)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)quant
- Quantile to computepublic static double quickSelect(double[] data, int start, int end, int rank)
data
- Data to processstart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static void insertionSort(double[] data, int start, int end)
data
- Data to sortstart
- Interval startend
- Interval endprivate static final void swap(double[] data, int a, int b)
data
- Arraya
- First indexb
- Second indexpublic static <T extends Comparable<? super T>> T quickSelect(T[] data, int rank)
T
- object typedata
- Data to processrank
- Rank position that we are interested in (integer!)public static <T extends Comparable<? super T>> T median(T[] data)
data
- Data to processpublic static <T extends Comparable<? super T>> T median(T[] data, int begin, int end)
T
- object typedata
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static <T extends Comparable<? super T>> T quantile(T[] data, double quant)
T
- object typedata
- Data to processquant
- Quantile to computepublic static <T extends Comparable<? super T>> T quantile(T[] data, int begin, int end, double quant)
T
- object typedata
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)quant
- Quantile to computepublic static <T extends Comparable<? super T>> void quickSelect(T[] data, int start, int end, int rank)
T
- object typedata
- Data to processstart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static <T extends Comparable<? super T>> void insertionSort(T[] data, int start, int end)
T
- object typedata
- Data to sortstart
- Interval startend
- Interval endprivate static final <T extends Comparable<? super T>> void swap(T[] data, int a, int b)
T
- object typedata
- Arraya
- First indexb
- Second indexpublic static <T extends Comparable<? super T>> T quickSelect(List<? extends T> data, int rank)
T
- object typedata
- Data to processrank
- Rank position that we are interested in (integer!)public static <T extends Comparable<? super T>> T median(List<? extends T> data)
T
- object typedata
- Data to processpublic static <T extends Comparable<? super T>> T median(List<? extends T> data, int begin, int end)
T
- object typedata
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static <T extends Comparable<? super T>> T quantile(List<? extends T> data, double quant)
T
- object typedata
- Data to processquant
- Quantile to computepublic static <T extends Comparable<? super T>> T quantile(List<? extends T> data, int begin, int end, double quant)
T
- object typedata
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)quant
- Quantile to computepublic static <T extends Comparable<? super T>> void quickSelect(List<? extends T> data, int start, int end, int rank)
T
- object typedata
- Data to processstart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static <T extends Comparable<? super T>> void insertionSort(List<T> data, int start, int end)
T
- object typedata
- Data to sortstart
- Interval startend
- Interval endprivate static final <T> void swap(List<T> data, int a, int b)
T
- object typedata
- Arraya
- First indexb
- Second indexpublic static <T> T quickSelect(List<? extends T> data, Comparator<? super T> comparator, int rank)
T
- object typedata
- Data to processcomparator
- Comparator to userank
- Rank position that we are interested in (integer!)public static <T> T median(List<? extends T> data, Comparator<? super T> comparator)
T
- object typedata
- Data to processcomparator
- Comparator to usepublic static <T> T median(List<? extends T> data, Comparator<? super T> comparator, int begin, int end)
T
- object typedata
- Data to processcomparator
- Comparator to usebegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static <T> T quantile(List<? extends T> data, Comparator<? super T> comparator, double quant)
T
- object typedata
- Data to processcomparator
- Comparator to usequant
- Quantile to computepublic static <T> T quantile(List<? extends T> data, Comparator<? super T> comparator, int begin, int end, double quant)
T
- object typedata
- Data to processcomparator
- Comparator to usebegin
- Begin of valid valuesend
- End of valid values (inclusive!)quant
- Quantile to computepublic static <T> void quickSelect(List<? extends T> data, Comparator<? super T> comparator, int start, int end, int rank)
T
- object typedata
- Data to processcomparator
- Comparator to usestart
- Interval startend
- Interval end (inclusive)rank
- rank position we are interested in (starting at 0)private static <T> void insertionSort(List<T> data, Comparator<? super T> comparator, int start, int end)
T
- object typedata
- Data to sortstart
- Interval startend
- Interval endpublic static void quickSelect(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int rank)
data
- Data to processcomparator
- Comparator to userank
- Rank position that we are interested in (integer!)public static int median(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator)
data
- Data to processcomparator
- Comparator to usepublic static int median(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int begin, int end)
data
- Data to processcomparator
- Comparator to usebegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static int quantile(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, double quant)
data
- Data to processcomparator
- Comparator to usequant
- Quantile to computepublic static int quantile(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int begin, int end, double quant)
data
- Data to processcomparator
- Comparator to usebegin
- Begin of valid valuesend
- End of valid values (exclusive)quant
- Quantile to computepublic static void quickSelect(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int start, int end, int rank)
data
- Data to processcomparator
- Comparator to usestart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static void insertionSort(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int start, int end, DBIDArrayIter iter1, DBIDArrayIter iter2)
data
- Data to sortstart
- Interval startend
- Interval endpublic static void quickSelect(ModifiableDoubleDBIDList data, int rank)
data
- Data to processrank
- Rank position that we are interested in (integer!)public static int median(ModifiableDoubleDBIDList data)
data
- Data to processpublic static int median(ModifiableDoubleDBIDList data, int begin, int end)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive!)public static int quantile(ModifiableDoubleDBIDList data, double quant)
data
- Data to processquant
- Quantile to computepublic static int quantile(ModifiableDoubleDBIDList data, int begin, int end, double quant)
data
- Data to processbegin
- Begin of valid valuesend
- End of valid values (exclusive)quant
- Quantile to computepublic static void quickSelect(ModifiableDoubleDBIDList data, int start, int end, int rank)
data
- Data to processstart
- Interval startend
- Interval end (exclusive)rank
- rank position we are interested in (starting at 0)private static void insertionSort(ModifiableDoubleDBIDList data, int start, int end, DoubleDBIDListIter iter1, DoubleDBIDListIter iter2)
data
- Data to sortstart
- Interval startend
- Interval endCopyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.