Exemple #1
0
        public void ContainsReturnsCorrectValue()
        {
            ChainHashTable <int, int> hashTable = new ChainHashTable <int, int>();

            hashTable.Add(1, 1);
            Assert.AreEqual(true, hashTable.Contains(1));
            Assert.AreEqual(false, hashTable.Contains(2));
        }
Exemple #2
0
        private static void UseChainHashTable(string[] words)
        {
            var htble     = new ChainHashTable <string, int>(40009);
            var htbleHelp = new ChainHashTable <string, int>(40009);

            for (int i = 0; i < words.Length; i++)
            {
                var slovo = words[i];
                if (htble.Contains(slovo))
                {
                    htble[slovo]++;
                    htbleHelp[slovo]++;
                }
                else
                {
                    htble.Add(slovo, 1);
                    htbleHelp.Add(slovo, 1);
                }
            }

            foreach (var pair in htbleHelp)
            {
                if (pair.Value > 27)
                {
                    htble.Remove(pair.Key);
                }
            }
        }