1
Vote

HashSetExtensionMethods.AddRange should return the added elements

description

It's often quite useful to know which elements of a sequence were added to the set. Changing the AddRange extension method to return IEnumerable<T> would make this much simpler:

public static IEnumerable<T> AddRange<T>(this HashSet<T> destination, IEnumerable<T> source)
{
if (null == destination) throw new ArgumentNullException("destination");
if (null == source) return Enumerable.Empty<T>();
return source.Where(destination.Add).ToArray();
}

comments