[][src]Function out::max_from_iter_unstable_by

pub fn max_from_iter_unstable_by<T>(
    iter: impl IntoIterator<Item = T>,
    n: usize,
    cmp: impl FnMut(&T, &T) -> Ordering
) -> Vec<T>

Get the n largest items from an iterator with a comparator 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 in most cases.

Panics

Panics if n > len.

Examples

let min = out::max_from_iter_unstable_by(-10..10, 3, |a, b| b.cmp(a));
assert_eq!(min, [-8, -9, -10]);