Skip to main content

nth_element

Function nth_element 

Source
pub fn nth_element(data: &mut Vec<f64>, k: usize) -> f64
Expand description

Quickselect O(n) algorithm: rearranges data so that data\[k\] holds the value that would be there in a fully sorted array, and returns it.

k must be < data.len().

ยงPanics

Panics if data is empty or k >= data.len().