public HashedSet <T> UnionWith(params ICollection <T>[] sets) { var result = new HashedSet <T>(); foreach (var item in this) { if (!result.Contains(item)) { result.Add(item); } } foreach (var set in sets) { foreach (var item in set) { if (!result.Contains(item)) { result.Add(item); } } } return(result); }
public HashedSet <T> UnionWith(IEnumerable <T> otherSet) { var result = new HashedSet <T>(); foreach (var item in this) { if (!result.Contains(item)) { result.Add(item); } } foreach (var item in otherSet) { if (!result.Contains(item)) { result.Add(item); } } return(result); }