Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
        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);
        }