@@ -164,6 +164,27 @@ public RangeSet<TRange, T> Union(RangeSet<TRange, T> other) =>
164164 other . Count == 0 ? this :
165165 Count == 0 ? other : From ( _elements . Concat ( other . _elements ) ) ;
166166
167+ /// <summary>
168+ /// Returns the union of <paramref name="left"/> and <paramref name="right"/>.
169+ /// </summary>
170+ /// <param name="left">The set to add to.</param>
171+ /// <param name="right">The range to add.</param>
172+ /// <returns>
173+ /// A normalized set containing every value of <paramref name="left"/> and of <paramref name="right"/>;
174+ /// the range is merged into existing elements where it overlaps or is adjacent.
175+ /// </returns>
176+ public static RangeSet < TRange , T > operator | ( RangeSet < TRange , T > left , TRange right ) =>
177+ left . Union ( right ) ;
178+
179+ /// <summary>
180+ /// Returns the union of <paramref name="left"/> and <paramref name="right"/>.
181+ /// </summary>
182+ /// <param name="left">The set to add to.</param>
183+ /// <param name="right">The set to combine with.</param>
184+ /// <returns>A normalized set containing every value of both sets.</returns>
185+ public static RangeSet < TRange , T > operator | ( RangeSet < TRange , T > left , RangeSet < TRange , T > right ) =>
186+ left . Union ( right ) ;
187+
167188 /// <summary>
168189 /// Returns the intersection of this set with <paramref name="other"/>.
169190 /// </summary>
@@ -206,6 +227,27 @@ public RangeSet<TRange, T> Intersect(RangeSet<TRange, T> other)
206227 return From ( results ) ;
207228 }
208229
230+ /// <summary>
231+ /// Returns the intersection of <paramref name="left"/> with <paramref name="right"/>.
232+ /// </summary>
233+ /// <param name="left">The set to intersect.</param>
234+ /// <param name="right">The range to intersect with.</param>
235+ /// <returns>
236+ /// A set containing, for each element of <paramref name="left"/>, its overlap with <paramref name="right"/>;
237+ /// <see cref="Empty"/> when nothing overlaps.
238+ /// </returns>
239+ public static RangeSet < TRange , T > operator & ( RangeSet < TRange , T > left , TRange right ) =>
240+ left . Intersect ( right ) ;
241+
242+ /// <summary>
243+ /// Returns the intersection of <paramref name="left"/> with <paramref name="right"/>.
244+ /// </summary>
245+ /// <param name="left">The set to intersect.</param>
246+ /// <param name="right">The set to intersect with.</param>
247+ /// <returns>A normalized set containing the values common to both sets.</returns>
248+ public static RangeSet < TRange , T > operator & ( RangeSet < TRange , T > left , RangeSet < TRange , T > right ) =>
249+ left . Intersect ( right ) ;
250+
209251 /// <summary>
210252 /// Returns what remains of this set after removing every value covered by <paramref name="other"/>.
211253 /// </summary>
@@ -233,6 +275,27 @@ public RangeSet<TRange, T> Except(TRange other)
233275 public RangeSet < TRange , T > Except ( RangeSet < TRange , T > other ) =>
234276 Enumerable . Aggregate ( other . _elements , this , ( current , range ) => current . Except ( range ) ) ;
235277
278+ /// <summary>
279+ /// Returns what remains of <paramref name="left"/> after removing every value covered by <paramref name="right"/>.
280+ /// </summary>
281+ /// <param name="left">The set to subtract from.</param>
282+ /// <param name="right">The range to subtract.</param>
283+ /// <returns>
284+ /// A normalized set of the remaining pieces; an element split by
285+ /// <paramref name="right"/> contributes both of its parts.
286+ /// </returns>
287+ public static RangeSet < TRange , T > operator - ( RangeSet < TRange , T > left , TRange right ) =>
288+ left . Except ( right ) ;
289+
290+ /// <summary>
291+ /// Returns what remains of <paramref name="left"/> after removing every value covered by <paramref name="right"/>.
292+ /// </summary>
293+ /// <param name="left">The set to subtract from.</param>
294+ /// <param name="right">The set to subtract.</param>
295+ /// <returns>A normalized set of the remaining pieces.</returns>
296+ public static RangeSet < TRange , T > operator - ( RangeSet < TRange , T > left , RangeSet < TRange , T > right ) =>
297+ left . Except ( right ) ;
298+
236299 /// <summary>
237300 /// Returns the complement of this set — every value of the domain not covered by it.
238301 /// </summary>
0 commit comments