Beispiel #1
0
        public void MyHashSetTest()
        {
            var hs = new MyHashSet();

            hs.Add(1);
            hs.Add(2);
            Assert.True(hs.Contains(1));
            Assert.False(hs.Contains(3));
            hs.Add(2);
            Assert.True(hs.Contains(2));
            hs.Remove(2);
            Assert.False(hs.Contains(2));
        }
Beispiel #2
0
        private void TestHashSet()
        {
            MyHashSet hashSet = new MyHashSet();

            hashSet.Add(1);
            hashSet.Add(2);
            Console.WriteLine("true:" + hashSet.Contains(1));    // returns true
            Console.WriteLine("false:" + hashSet.Contains(3));   // returns false (not found)
            hashSet.Add(2);
            Console.WriteLine("true:" + hashSet.Contains(2));    // returns true
            hashSet.Remove(2);
            Console.WriteLine("false:" + hashSet.Contains(2));   // returns false (already removed)
        }