public void Union(CustomHashSet <T> another) { foreach (var entry in another) { var entryHashCode = entry.GetHashCode(); if (!this.data.Keys.Contains(entryHashCode)) { this.data.Add(entryHashCode, entry); } } }
public CustomHashSet <T> Intersect(CustomHashSet <T> another) { var result = new CustomHashSet <T>(); foreach (var entry in another) { var entryHashCode = entry.GetHashCode(); if (this.data.Keys.Contains(entryHashCode)) { result.data.Add(entryHashCode, entry); } } return(result); }