Closesdotnet/corefx#2323
A straight-forward implementation, forgoing any optimisations.
HashSet's constructor already has some for some cases, and others
could be wasteful unless not just the number of elements, but the
number of elements that are distinct in terms of the equality
comparer can be predicted.
Commit migrated from https://github.com/dotnet/corefx/commit/c0e67b29c4bc1cbb5fa8b82817a73c1e64a560f4