public final class QuickSelect extends Object
Modifier and Type | Method and Description |
---|---|
static double |
select(double[] arr,
int lo,
int hi,
int pivot)
Gets the 0-based kth order statistic from the array.
|
static long |
select(long[] arr,
int lo,
int hi,
int pivot)
Gets the 0-based kth order statistic from the array.
|
static double |
selectExcludingZeros(double[] arr,
int nonZeros,
int pivot)
Gets the 1-based kth order statistic from the array excluding any zero values in the
array.
|
static long |
selectExcludingZeros(long[] arr,
int nonZeros,
int pivot)
Gets the 1-based kth order statistic from the array excluding any zero values in the
array.
|
static double |
selectIncludingZeros(double[] arr,
int pivot)
Gets the 1-based kth order statistic from the array including any zero values in the
array.
|
static long |
selectIncludingZeros(long[] arr,
int pivot)
Gets the 1-based kth order statistic from the array including any zero values in the
array.
|
public static long select(long[] arr, int lo, int hi, int pivot)
arr
- The array to be re-arranged.lo
- The lowest 0-based index to be considered.hi
- The highest 0-based index to be considered.pivot
- The 0-based index of the value to pivot on.public static long selectIncludingZeros(long[] arr, int pivot)
arr
- The hash array.pivot
- The 1-based index of the value that is chosen as the pivot for the array.
After the operation all values below this 1-based index will be less than this value
and all values above this index will be greater. The 0-based index of the pivot will be
pivot-1.public static long selectExcludingZeros(long[] arr, int nonZeros, int pivot)
arr
- The hash array.nonZeros
- The number of non-zero values in the array.pivot
- The 1-based index of the value that is chosen as the pivot for the array.
After the operation all values below this 1-based index will be less than this value
and all values above this index will be greater. The 0-based index of the pivot will be
pivot+arr.length-nonZeros-1.public static double select(double[] arr, int lo, int hi, int pivot)
arr
- The array to be re-arranged.lo
- The lowest 0-based index to be considered.hi
- The highest 0-based index to be considered.pivot
- The 0-based smallest value to pivot on.public static double selectIncludingZeros(double[] arr, int pivot)
arr
- The hash array.pivot
- The 1-based index of the value that is chosen as the pivot for the array.
After the operation all values below this 1-based index will be less than this value
and all values above this index will be greater. The 0-based index of the pivot will be
pivot-1.public static double selectExcludingZeros(double[] arr, int nonZeros, int pivot)
arr
- The hash array.nonZeros
- The number of non-zero values in the array.pivot
- The 1-based index of the value that is chosen as the pivot for the array.
After the operation all values below this 1-based index will be less than this value
and all values above this index will be greater. The 0-based index of the pivot will be
pivot+arr.length-nonZeros-1.Copyright © 2015–2021 The Apache Software Foundation. All rights reserved.