Function fera_graph::max_by_prop
[−]
[src]
pub fn max_by_prop<I, P, K>(prop: P, iter: I) -> Option<I::Item> where
I: IntoIterator,
I::Item: Copy + IntoOwned<K>,
P: PropGet<K>,
P::Output: Ord,
Returns the iterator's item with maximum property value or None
if the iterator is empty.
If several items have equally maximum property value, the last item with maximum property value is returned.
Example
use fera_graph::prelude::*; use fera_graph::max_by_prop; let g = CompleteGraph::new(4); let mut w = g.default_vertex_prop(0u32); w[0] = 5; w[1] = 10; w[2] = 3; w[3] = 10; assert_eq!(Some(3), max_by_prop(&w, g.vertices())); assert_eq!(None, max_by_prop(&w, g.vertices().take(0))); assert_eq!(Some(&0), max_by_prop(&w, &[0, 2]));