Exemplo n.º 1
0
        private static void HashTableTest(IEnumerable<string> words)
        {
            var table = new HashTable<string, int>();
            foreach (var word in words)
            {
                if (table.ContainsKey(word))
                {
                    table[word]++;
                }
                else
                {
                    table.Add(word, 1);
                }
            }

            var wordsWithSevenLetters = table.Where(word => word.Key.Length == 7).Select(item => item.Key).ToArray();

            foreach (var sevenLetterWord in wordsWithSevenLetters)
            {
                table.Remove(sevenLetterWord);
            }
        }