Beispiel #1
0
        public void FindTest()
        {
            OpenAddressHashTable <int, int> hashTable = new OpenAddressHashTable <int, int>();

            for (int i = 0; i < 10000; i++)
            {
                hashTable.Add(i, i);
            }

            for (int i = 100; i < 1000; i++)
            {
                hashTable.Remove(i);
            }

            bool result = false;

            for (int i = 100; i < 1000; i++)
            {
                result = result || hashTable.Contains(i);
            }

            bool resultTrue = true;

            for (int i = 0; i < 100; i++)
            {
                resultTrue = resultTrue & hashTable.Contains(i);
            }
            Assert.IsFalse(result);
            Assert.IsTrue(resultTrue);
        }
Beispiel #2
0
        private static void TestingHashTable(OpenAddressHashTable <string, int> hashTable, string[] words)
        {
            foreach (var el in words)
            {
                if (hashTable.Contains(el))
                {
                    hashTable[el] = hashTable[el] + 1;
                }
                else
                {
                    hashTable.Add(el, 0);
                }
            }

            List <string> words7 = new List <string>();

            foreach (var pair in hashTable)
            {
                if (pair.Key.Length == 7)
                {
                    words7.Add(pair.Key);
                }
            }

            foreach (var el in words7)
            {
                hashTable.Remove(el);
            }
        }
Beispiel #3
0
        public void CollissionTest()
        {
            OpenAddressHashTable <int, int> hashTable = new OpenAddressHashTable <int, int>();

            hashTable.Add(1, 1);
            hashTable.Add(374, 374);
            hashTable.Add(5, 5);
            hashTable.Add(2, 2);

            hashTable.Remove(1);

            Assert.IsTrue(hashTable.Contains(374));
        }
Beispiel #4
0
        public void RemoveTest()
        {
            OpenAddressHashTable <int, int> hashTable = new OpenAddressHashTable <int, int>();

            for (int i = 0; i < 10000; i++)
            {
                hashTable.Add(i, i);
            }

            for (int i = 100; i < 1000; i++)
            {
                hashTable.Remove(i);
            }

            Assert.AreEqual(9100, hashTable.Count);
        }