pub trait MultiwayRangeMapBlaze<T: Integer, V: Eq + Clone>: IntoIterator<Item = RangeMapBlaze<T, V>> {
// Provided methods
fn union(self) -> RangeMapBlaze<T, V>
where Self: Sized { ... }
fn intersection(self) -> RangeMapBlaze<T, V>
where Self: Sized { ... }
fn symmetric_difference(self) -> RangeMapBlaze<T, V>
where Self: Sized { ... }
}Expand description
Provides methods on zero or more RangeMapBlaze’s,
specifically union, intersection and symmetric_difference.
Also see MultiwayRangeMapBlazeRef.
Provided Methods§
Sourcefn union(self) -> RangeMapBlaze<T, V>where
Self: Sized,
fn union(self) -> RangeMapBlaze<T, V>where
Self: Sized,
Unions the given RangeMapBlaze’s, creating a new RangeMapBlaze.
Any number of input can be given.
For exactly two inputs, you can also use the ‘|’ operator.
Also see MultiwayRangeMapBlazeRef::union.
§Performance
All work is done on demand, in one pass through the inputs. Minimal memory is used.
§Example
Find the integers that appear in any of the RangeMapBlaze’s.
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
let union = [a, b, c].union();
assert_eq!(union.to_string(), r#"(1..=2, "c"), (3..=4, "b"), (5..=100, "c"), (101..=200, "a")"#);Sourcefn intersection(self) -> RangeMapBlaze<T, V>where
Self: Sized,
fn intersection(self) -> RangeMapBlaze<T, V>where
Self: Sized,
Intersects the given RangeMapBlaze’s, creating a new RangeMapBlaze.
Any number of input can be given.
For exactly two inputs, you can also use the ‘&’ operator.
Also see MultiwayRangeMapBlazeRef::intersection.
§Panics
The intersection of zero maps causes a panic. Mathematically, it could be a mapping from all integers to some fill-in value but we don’t implement that.
§Performance
All work is done on demand, in one pass through the inputs. Minimal memory is used.
§Example
Find the integers that appear in all the RangeMapBlaze’s.
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
let intersection = [a, b, c].intersection();
assert_eq!(intersection.to_string(), r#"(2..=2, "c"), (6..=6, "c")"#);Sourcefn symmetric_difference(self) -> RangeMapBlaze<T, V>where
Self: Sized,
fn symmetric_difference(self) -> RangeMapBlaze<T, V>where
Self: Sized,
Symmetric difference on the given RangeMapBlaze’s, creating a new RangeMapBlaze.
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
let symmetric_difference = [a, b, c].symmetric_difference();
assert_eq!(symmetric_difference.to_string(), r#"(1..=2, "c"), (3..=4, "b"), (6..=6, "c"), (101..=200, "a")"#);