Esempio n. 1
0
 /// <summary>
 /// See also https://msdn.microsoft.com/en-us/library/bb460136(v=vs.110).aspx
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Bag <T> Intersect <T>(this Bag <T> a, Bag <T> b)
 => a.DifSelectMany(b, v => Math.Min(v.A, v.B));
Esempio n. 2
0
 /// <summary>
 /// See also https://msdn.microsoft.com/en-us/library/bb341731(v=vs.110).aspx
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Bag <T> Union <T>(this Bag <T> a, Bag <T> b)
 => a.DifSelectMany(b, v => Math.Max(v.A, v.B));
Esempio n. 3
0
 /// <summary>
 /// See also https://msdn.microsoft.com/en-us/library/bb300779(v=vs.110).aspx
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Bag <T> Except <T>(this Bag <T> a, Bag <T> b)
 => a.DifSelectMany(b, v => v.A - v.B);