Trait MultiwaySortedDisjointMap

Source
pub trait MultiwaySortedDisjointMap<T, VR, I>: IntoIterator<Item = I> + Sized
where T: Integer, VR: ValueRef, I: SortedDisjointMap<T, VR>,
{ // Provided methods fn union(self) -> UnionKMergeMap<T, VR, I> { ... } fn intersection<'a>(self) -> IntersectionKMap<'a, T, VR, I> { ... } fn symmetric_difference(self) -> SymDiffKMergeMap<T, VR, I> { ... } }
Expand description

Provides methods on zero or more SortedDisjointMap iterators, specifically union, intersection, and symmetric_difference.

Provided Methods§

Source

fn union(self) -> UnionKMergeMap<T, VR, I>

Unions the given SortedDisjointMap iterators, creating a new SortedDisjointMap iterator. The input iterators must be of the same type. Any number of input iterators can be given.

For input iterators of different types, use the union_dyn! macro.

For exactly two inputs, you can also use the | operator.

§Performance

All work is done on demand, in one pass through the input iterators. Minimal memory is used.

§Example

Find the integers that appear in any of the SortedDisjointMap iterators.

use range_set_blaze::prelude::*;

let a = CheckSortedDisjointMap::new(vec![(2..=2, &"a"), (6..=200, &"a")]);
let b = CheckSortedDisjointMap::new(vec![(2..=6, &"b")]);
let c = CheckSortedDisjointMap::new(vec![(1..=2, &"c"), (5..=100, &"c")]);

let union = [a, b, c].union();

assert_eq!(union.into_string(), r#"(1..=2, "c"), (3..=4, "b"), (5..=100, "c"), (101..=200, "a")"#);
Source

fn intersection<'a>(self) -> IntersectionKMap<'a, T, VR, I>

Intersects the given SortedDisjointMap iterators, creating a new SortedDisjointMap iterator. The input iterators must be of the same type. Any number of input iterators can be given.

For input iterators of different types, use the intersection_dyn! macro.

For exactly two inputs, you can also use the & operator.

§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 input iterators. Minimal memory is used.

§Example

Find the integers that appear in all the SortedDisjointMap iterators.

use range_set_blaze::prelude::*;

let a = CheckSortedDisjointMap::new(vec![(2..=2, &"a"), (6..=200, &"a")]);
let b = CheckSortedDisjointMap::new(vec![(2..=6, &"b")]);
let c = CheckSortedDisjointMap::new(vec![(1..=2, &"c"), (5..=100, &"c")]);

let intersection = [a, b, c].intersection();

assert_eq!(intersection.into_string(), r#"(2..=2, "c"), (6..=6, "c")"#);
Source

fn symmetric_difference(self) -> SymDiffKMergeMap<T, VR, I>

Symmetric difference on the given SortedDisjointMap iterators, creating a new SortedDisjointMap iterator.

For input iterators of different types, use the symmetric_difference_dyn! macro.

For exactly two inputs, you can also use the ^ operator.

use range_set_blaze::prelude::*;

let a = CheckSortedDisjointMap::new(vec![(2..=2, &"a"), (6..=200, &"a")]);
let b = CheckSortedDisjointMap::new(vec![(2..=6, &"b")]);
let c = CheckSortedDisjointMap::new(vec![(1..=2, &"c"), (5..=100, &"c")]);

let symmetric_difference = [a, b, c].symmetric_difference();

assert_eq!(symmetric_difference.into_string(), r#"(1..=2, "c"), (3..=4, "b"), (6..=6, "c"), (101..=200, "a")"#);

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.

Implementors§

Source§

impl<T, VR, II, I> MultiwaySortedDisjointMap<T, VR, I> for II
where T: Integer, VR: ValueRef, I: SortedDisjointMap<T, VR>, II: IntoIterator<Item = I>,