[][src]Function out::max_unstable

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

Get the n largest items.

This function is not stable, i.e. it may not preserve the order of equal elements. This function should be faster than max in most cases.

Panics

Panics if n > len.

Examples

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