Esempio 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"));
        }
Esempio 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");
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hash table demo");
            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("5th index value: " + hash5);
            string hash2 = hash.Get("2");

            Console.WriteLine("2th index value: " + hash2);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hash table demo");
            MyMapNode <string, string> hash = new MyMapNode <string, string>(5);
            string para = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations";

            string[] paraWords = para.Split(' ');
            int      pLength   = paraWords.Length;

            for (int i = 0; i < pLength; i++)
            {
                hash.Add(Convert.ToString(i), paraWords[i]);
            }
            foreach (string word in paraWords)
            {
                hash.GetFrequency(word);
            }
            Console.ReadKey();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Welcome to Hashmap.");
            /// Create a  reference of MyMapNode
            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");
            hash.GetFrequency("To");

            string hashFive = hash.Get("5");

            Console.WriteLine("5th index value is: " + hashFive);

            string hashTwo = hash.Get("2");

            Console.WriteLine("2nd index value is: " + hashTwo);
        }