[][src]Function out::max_from_iter_unstable_by_key

pub fn max_from_iter_unstable_by_key<T, K: Ord>(
    iter: impl IntoIterator<Item = T>,
    n: usize,
    f: impl FnMut(&T) -> K
) -> Vec<T>

Get the n largest items from an iterator with a key extraction function.

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

Panics

Panics if n > len.

Examples

let max = out::max_from_iter_unstable_by_key(-10_i32..10, 3, |a| a.abs());
assert_eq!(max, [9, -9, -10]);