Module fera_graph::ext
[−]
[src]
Extension traits for std types.
The traits is this module are included in the prelude.
Examples
extern crate fera_fun; extern crate fera_graph; use fera_graph::prelude::*; use fera_fun::vec; let g = CompleteGraph::new(4); let mut w = g.default_vertex_prop(0); w[0] = 1; w[1] = 2; w[2] = 3; w[3] = 0; let mut vertices = vec(g.vertices()); assert!(!vertices.is_sorted_by_prop(&w)); vertices.sort_by_prop(&w); assert!(vertices.is_sorted_by_prop(&w)); assert_eq!(vec![3, 0, 1, 2], vertices); // returns the index of the vertex with w = 2, // that is, the index of vertex 1 assert_eq!(Ok(2), vertices.binary_search_by_prop(&2, &w)); // returns the index that a vertex with w = 5 // could be inserted while maintaining sorted order assert_eq!(Err(4), vertices.binary_search_by_prop(&5, &w));
Traits
GraphsSliceExt |
Extension trait for slices. |
GraphsVecExt |
Extension trait for vectors. |