Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int frequency;

            Console.WriteLine("Welcome To Hash Table Program");
            MyMapNode <string, int> hash = new MyMapNode <string, int>(5);
            string paragraph             = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations";

            string[] words = paragraph.Split(" ");
            for (int i = 0; i < words.Length; i++)
            {
                if (hash.GetFrequency(words[i]) == default)
                {
                    frequency = 1;
                    hash.Add(words[i], frequency);
                }
                else
                {
                    frequency = hash.GetFrequency(words[i]);
                    hash.SetFrequency(words[i], ++frequency);
                }
            }
            Console.WriteLine("Frequency :" + hash.GetFrequency("avoidable"));
            hash.Remove("avoidable");
            Console.WriteLine("Frequency after removing :" + hash.GetFrequency("avoidable"));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MyMapNode <string, string> hash = new MyMapNode <string, string>(5);

            hash.Add("0", "To");
            hash.Add("1", "be");
            hash.Add("2", "or");
            hash.Add("3", "not");
            hash.Add("4", "to");
            hash.Add("5", "be");

            string hash5 = hash.get("5");

            Console.WriteLine(hash5);

            hash.Remove("5");
        }