Macro range_set_blaze::intersection_dyn
source · macro_rules! intersection_dyn { ($($val:expr),*) => { ... }; }
Expand description
Intersects one or more SortedDisjoint iterators, creating a new SortedDisjoint iterator.
The input iterators need not to be of the same type.
For input iterators of the same type, intersection may be slightly faster.
§Performance
All work is done on demand, in one pass through the input iterators. Minimal memory is used.
§Example: 3-Input Parity
Find the integers that appear an odd number of times in the SortedDisjoint iterators.
use range_set_blaze::prelude::*;
let a = RangeSetBlaze::from_iter([1..=6, 8..=9, 11..=15]);
let b = RangeSetBlaze::from_iter([5..=13, 18..=29]);
let c = RangeSetBlaze::from_iter([38..=42]);
let parity = union_dyn!(
intersection_dyn!(a.ranges(), !b.ranges(), !c.ranges()),
intersection_dyn!(!a.ranges(), b.ranges(), !c.ranges()),
intersection_dyn!(!a.ranges(), !b.ranges(), c.ranges()),
intersection_dyn!(a.ranges(), b.ranges(), c.ranges())
);
assert_eq!(
parity.to_string(),
"1..=4, 7..=7, 10..=10, 14..=15, 18..=29, 38..=42"
);