org.apache.commons.math3.util

## Class KthSelector

- java.lang.Object
- - org.apache.commons.math3.util.KthSelector

- All Implemented Interfaces:
    Serializable

      public class KthSelector
      extends Object
      implements Serializable

  A 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 and Description
    `KthSelector()` Constructor with default `median of 3` pivoting strategy
    `KthSelector(PivotingStrategyInterface pivotingStrategy)` Constructor with specified pivoting strategy

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PivotingStrategyInterface` | `getPivotingStrategy()` Get the pivotin strategy.
    `double` | `select(double[] work, int[] pivotsHeap, int k)` Select Kth value in the array.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KthSelector

          public KthSelector()

      Constructor with default `median of 3` pivoting 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 value
        `pivotsHeap` - cached pivots heap that can be used for efficient estimation
        `k` - the index whose value in the array is of interest
      Returns:
        Kth value

Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.