the array being worked upon.
the order statistic being looked for (starting from zero). In particular, there should be 'k' elements in the array for which the predicate will return true.
predicate used for array element comparisons. Takes two array elements to be compared and returns true/false based upon the comparison. (defaults to a comparison using "<" if no predicate is given)
the index of the kth element in the array as defined by the ordering predicate.
new Exception if input array is empty.
Selects the kth element of an array as defined by the given predicate.
Notes: -> Uses the Quickselect selection algorithm (http://en.wikipedia.org/wiki/Quickselect) -> Typically, Quickselect is used to select the kth smallest element of an array, but this function can also be used to select elements ordered in any fashion, as defined by the given predicate. -> The array elements may be reordered during the selection process. -> The following would be true if the selection happens successfully (i.e. if no exception is thrown): * the kth element in the array as defined by the given predicate would have been moved to index 'k'. * All elements before index 'k' are guaranteed to be passed by the predicate compared to element 'k' (i.e. the predicate would return true) whereas all elements after index 'k' are guaranteed to not be passed by the predicate compared to element 'k' (i.e. the predicate would return false). This means that, if the kth smallest element is being selected, then all elements before the kth smallest element would be lesser than it and all elements after the kth smallest element would be greater than or equal to it. However, no guarantees are made about the sorting order of the elements before/after the kth smallest element. In other words, unordered partial sorting of the array will take place. -> The result is defined only if all values in the array are ordered (unordered values like floating-point NaNs could result in undefined behaviour).