Kiểm tra đoạn mã này từ Linq.Enumerable
lớp:nội System.Linq.Set <T> vs System.Collections.Generic.HashSet công <T>
static IEnumerable<TSource> DistinctIterator<TSource>(IEnumerable<TSource> source, IEqualityComparer<TSource> comparer) {
Set<TSource> set = new Set<TSource>(comparer);
foreach (TSource element in source)
if (set.Add(element)) yield return element;
}
Tại sao những kẻ tại Microsoft quyết định sử dụng thực hiện nội bộ này Set
và không phải là HashSet
thông thường? Nếu nó tốt hơn trong bất kỳ cách nào, tại sao không tiếp xúc với công chúng?