Macro range_set_blaze::union_map_dyn
source · macro_rules! union_map_dyn { ($($val:expr),*) => { ... }; }
Expand description
Unions one or more SortedDisjointMap iterators, creating a new SortedDisjointMap iterator.
The input iterators need not to be of the same type.
For input iterators of the same type, union 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 SortedDisjointMap 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_map_dyn!(
intersection_map_dyn!(a.ranges(), !b.ranges(), !c.ranges()),
intersection_map_dyn!(!a.ranges(), b.ranges(), !c.ranges()),
intersection_map_dyn!(!a.ranges(), !b.ranges(), c.ranges()),
intersection_map_dyn!(a.ranges(), b.ranges(), c.ranges())
);
assert_eq!(
parity.into_string(),
"1..=4, 7..=7, 10..=10, 14..=15, 18..=29, 38..=42"
);