pub trait ConvexHull<T> {
// Required method
fn convex_hull<U: IntoIterator<Item = T>>(iter: U) -> Self;
}Expand description
Defines the minimal contiguous Interval which fully contains every provided item.
§Example
use intervalsets::{ConvexHull, Interval, IntervalSet};
use intervalsets::ops::Union;
// from points on the number line
let hull = Interval::convex_hull([5, 3, -120, 44, 100, -100]);
assert_eq!(hull, Interval::closed(-120, 100));
// from intervals
let intervals = vec![
Interval::open(30.0, 50.0),
Interval::closed(20.0, 40.0),
Interval::closed(1000.0, 2000.0),
Interval::unbound_open(0.0),
];
let hull = Interval::convex_hull(intervals);
assert_eq!(hull, Interval::unbound_closed(2000.0));
// from sets
let sets: Vec<IntervalSet<i32>> = vec![
Interval::closed(0, 10).union(&Interval::closed(1000, 1010)),
Interval::closed(-1000, 10).into(),
Interval::closed(-500, 500).union(&Interval::closed_unbound(800))
];
let hull: Interval<i32> = Interval::convex_hull(sets);
assert_eq!(hull, Interval::closed_unbound(-1000))Required Methods§
fn convex_hull<U: IntoIterator<Item = T>>(iter: U) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.