[][src]Function out::max_from_iter_by

pub fn max_from_iter_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 stable, i.e. it preserves the order of equal elements.

Panics

Panics if n > len.

Examples

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