Example #1
0
 public MyHashedSet(MyHashedSet <T> hashedSet)
     : this()
 {
     foreach (var element in hashedSet)
     {
         this.elements.Set(element, true);
     }
 }
Example #2
0
 public void UnionWith(MyHashedSet <T> other)
 {
     foreach (var element in other)
     {
         if (!this.Contains(element))
         {
             this.Add(element);
         }
     }
 }
Example #3
0
        public void IntersectWith(MyHashedSet <T> other)
        {
            var resultTable = new MyHashTable <T, bool>();

            foreach (var element in other)
            {
                if (this.Contains(element))
                {
                    resultTable.Set(element, true);
                }
            }

            this.elements = resultTable;
        }
Example #4
0
        static void Main(string[] args)
        {
            MyHashedSet <string> aspNetStudents = new MyHashedSet <string>();

            aspNetStudents.Add("S. Jobs");
            aspNetStudents.Add("B. Gates");
            aspNetStudents.Add("M. Dell");
            MyHashedSet <string> silverlightStudents = new MyHashedSet <string>();

            silverlightStudents.Add("M. Zuckerberg");
            silverlightStudents.Add("M. Dell");
            MyHashedSet <string> allStudents = new MyHashedSet <string>();

            allStudents.UnionWith(aspNetStudents);
            allStudents.UnionWith(silverlightStudents);
            MyHashedSet <string> intersectStudents = new MyHashedSet <string>(aspNetStudents);

            intersectStudents.IntersectWith(silverlightStudents);
            Console.WriteLine("ASP.NET students: " + string.Join(", ", aspNetStudents));
            Console.WriteLine("Silverlight students: " + string.Join(", ", silverlightStudents));
            Console.WriteLine("All students: " + string.Join(", ", allStudents));
            Console.WriteLine("Students in both ASP.NET and Silverlight: " + string.Join(", ", intersectStudents));
        }