/// <summary> /// Se also https://msdn.microsoft.com/en-us/library/bb352880(v=vs.110).aspx /// </summary> /// <typeparam name="T"></typeparam> /// <param name="input"></param> /// <param name="value"></param> /// <returns></returns> public static Bag <bool> Contains <T>(this Bag <T> input, T value) => input.Any(v => v.Equals(value));
/// <summary> /// See also https://msdn.microsoft.com/en-us/library/bb360179(v=vs.110).aspx /// and https://msdn.microsoft.com/en-us/library/bb355419(v=vs.110).aspx /// </summary> /// <typeparam name="T"></typeparam> /// <param name="input"></param> /// <param name="value"></param> /// <returns></returns> public static Bag <T> DefaultIfEmpty <T>(this Bag <T> input, T value = default(T)) => input .Any() .Where(any => !any) .Select(_ => value) .DisjointUnion(input);
/// <summary> /// See also https://msdn.microsoft.com/en-us/library/bb337697(v=vs.110).aspx /// </summary> /// <typeparam name="T"></typeparam> /// <param name="input"></param> /// <returns></returns> public static Bag <bool> Any <T>(this Bag <T> input) => input.Any(_ => true);