You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight crate that brings to Rust an nth_element implementation that leverages Andrei Alexandrescu's adaptive quickselect algorithm. Also available on crates.io.
Installation
Be sure that your Cargo.toml looks somewhat like this:
[dependencies]
adqselect = "0.1.3"
Usage
Bring the crate into scope:
externcrate adqselect;use adqselect::nth_element;
then simply call nth_element on a vector.
letmut v = vec![10,7,9,7,2,8,8,1,9,4];nth_element(&mut v,3,&mutOrd::cmp);assert_eq!(v[3],7);
This implementation also handles generic data types as long as they satisfy the PartialEq and PartialOrd traits.
This chart shows the relationship between function/parameter and iteration time. The thickness of the shaded
region indicates the probability that a measurement of the given function/parameter would take a particular
length of time.
Line Chart
This chart shows the mean measured time for each function as the input (or the size of the input) increases.