[][src]Function out::slice::max_unstable

pub fn max_unstable<T: Ord>(v: &mut [T], n: usize) -> &mut [T]

Returns the n largest items.

This sort is unstable (i.e. may reorder equal elements), in-place (i.e. does not allocate), and typically faster than max.

Panics

Panics if n > len.

Examples

let mut v = [-5, 4, 1, -3, 2];
let max = out::slice::max_unstable(&mut v, 3);
assert_eq!(max, [1, 2, 4]);