1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
use ;
use crate::;
use Box;
/// Gives [`SortedDisjointMap`] iterators a uniform type. Used by the [`union_map_dyn`], etc. macros to give all
/// their input iterators the same type.
///
/// [`SortedDisjointMap`]: trait.SortedDisjointMap.html#table-of-contents
/// [`union_map_dyn`]: crate::union_map_dyn
/// [`intersection_map_dyn`]: crate::intersection_map_dyn
///
/// # Example
/// ```
/// use range_set_blaze::prelude::*;
///
/// let a = RangeMapBlaze::from_iter([(38..=42, "a")]);
/// let b = CheckSortedDisjointMap::new([(5..=13, &"b"), (18..=29, &"b")]);
/// let c = RangeMapBlaze::from_iter([(1..=6, "c"), (8..=9, "c"), (11..=15, "c")]);
/// let union = [
/// DynSortedDisjointMap::new(a.range_values()),
/// DynSortedDisjointMap::new(b),
/// DynSortedDisjointMap::new(c.range_values()),
/// ].union();
/// assert_eq!(union.into_string(), r#"(1..=6, "c"), (7..=7, "b"), (8..=9, "c"), (10..=10, "b"), (11..=15, "c"), (18..=29, "b"), (38..=42, "a")"#);
/// ```
// Constructs a `DynSortedDisjointMap` encapsulating a `SortedDisjointMap` iterator.
// The lifetime `'a` ensures that any references held by the iterator are valid
// for the duration of the `DynSortedDisjointMap`'s existence. This is crucial for
// preventing dangling references and ensuring memory safety when the iterator
// contains references to data outside of itself.
/// Intersects zero or more [`SortedDisjointMap`] iterators,
/// creating a new [`SortedDisjointMap`] iterator.
/// The input iterators need not 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.
///
/// [`SortedDisjointMap`]: crate::SortedDisjointMap.html#table-of-contents
/// [`intersection`]: crate::MultiwaySortedDisjointMap::intersection
/// # Examples
///
/// ```
/// use range_set_blaze::prelude::*;
///
/// let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
/// let b = CheckSortedDisjointMap::new([(2..=6, &"b")]);
/// let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
/// let intersection = intersection_map_dyn!(a.range_values(), b, c.range_values());
/// assert_eq!(intersection.into_string(), r#"(2..=2, "c"), (6..=6, "c")"#);
/// ```
/// Unions zero or more [`SortedDisjointMap`] iterators,
/// creating a new [`SortedDisjointMap`] iterator.
/// The input iterators need not 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.
///
/// [`SortedDisjointMap`]: crate::SortedDisjointMap.html#table-of-contents
/// [`union`]: crate::MultiwaySortedDisjointMap::union
/// # Examples
///
/// ```
/// use range_set_blaze::prelude::*;
///
/// let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
/// let b = CheckSortedDisjointMap::new([(2..=6, &"b")]);
/// let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
/// let union = union_map_dyn!(a.range_values(), b, c.range_values());
/// assert_eq!(union.into_string(), r#"(1..=2, "c"), (3..=4, "b"), (5..=100, "c"), (101..=200, "a")"#);
/// ```
/// Computes the symmetric difference of zero or more [`SortedDisjointMap`] iterators,
/// creating a new [`SortedDisjointMap`] iterator.
/// The input iterators need not be of the same type.
///
/// For input iterators of the same type, [`symmetric_difference`] may be slightly faster.
///
/// # Performance
/// All work is done on demand, in one pass through the input iterators. Minimal memory is used.
///
/// [`SortedDisjointMap`]: crate::SortedDisjointMap.html#table-of-contents
/// [`symmetric_difference`]: crate::MultiwaySortedDisjointMap::symmetric_difference
/// # Examples
///
/// ```
/// use range_set_blaze::prelude::*;
///
/// let a = RangeMapBlaze::from_iter([(2..=2, "a"), (6..=200, "a")]);
/// let b = CheckSortedDisjointMap::new([(2..=6, &"b")]);
/// let c = RangeMapBlaze::from_iter([(1..=2, "c"), (5..=100, "c")]);
/// let sym_diff = symmetric_difference_map_dyn!(a.range_values(), b, c.range_values());
/// assert_eq!(sym_diff.into_string(), r#"(1..=2, "c"), (3..=4, "b"), (6..=6, "c"), (101..=200, "a")"#);
/// ```