Package org.apache.commons.math4.util
Class KthSelector
- java.lang.Object
-
- org.apache.commons.math4.util.KthSelector
-
- All Implemented Interfaces:
java.io.Serializable
public class KthSelector extends java.lang.Object implements java.io.SerializableA Simple Kth selector implementation to pick up the Kth ordered element from a work array containing the input numbers.- Since:
- 3.4
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KthSelector()Constructor with defaultmedian of 3pivoting strategyKthSelector(PivotingStrategyInterface pivotingStrategy)Constructor with specified pivoting strategy
-
Method Summary
Modifier and Type Method Description PivotingStrategyInterfacegetPivotingStrategy()Get the pivotin strategy.doubleselect(double[] work, int[] pivotsHeap, int k)Select Kth value in the array.
-
-
-
Constructor Detail
-
KthSelector
public KthSelector()
Constructor with defaultmedian of 3pivoting strategy
-
KthSelector
public KthSelector(PivotingStrategyInterface pivotingStrategy) throws NullArgumentException
Constructor with specified pivoting strategy- Parameters:
pivotingStrategy- pivoting strategy to use- Throws:
NullArgumentException- when pivotingStrategy is null- See Also:
MedianOf3PivotingStrategy,RandomPivotingStrategy,CentralPivotingStrategy
-
-
Method Detail
-
getPivotingStrategy
public PivotingStrategyInterface getPivotingStrategy()
Get the pivotin strategy.- Returns:
- pivoting strategy
-
select
public double select(double[] work, int[] pivotsHeap, int k)Select Kth value in the array.- Parameters:
work- work array to use to find out the Kth valuepivotsHeap- cached pivots heap that can be used for efficient estimationk- the index whose value in the array is of interest- Returns:
- Kth value
-
-