Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!WELCOME TO HASHTABLE");
            Console.WriteLine("Hash table demo"); //() []
            MyMapNode <string, string> hash = new MyMapNode <string, string>(5);

            hash.Add("0", "To be or not to be");
            hash.frequencyOfWords("0");
            hash.Add("1", "A random paragraph can also be an excellent way for a writer to tackle writers' block. Writing block can often happen due to being stuck with a current project that the writer is trying to complete. By inserting a completely random paragraph from which to begin, it can take down some of the issues that may have been causing the writers' block in the first place.");
            hash.frequencyOfWords("1");

            string paragraph = "A random paragraph can also be an excellent way for a writer to tackle writers' block. Writing block can often happen due to being stuck with a current project that the writer is trying to complete. By inserting a completely random paragraph from which to begin, it can take down some of the issues that may have been causing the writers' block in the first place.";

            string[] para = paragraph.Split(" ");
            MyMapNode <int, string> hash1 = new MyMapNode <int, string>(para.Length);
            int key = 0;

            foreach (string word in para)
            {
                hash1.Add(key, word);
                key++;
            }

            hash.Remove(hash1, "avoidable");
        }
Beispiel #2
0
 /// <summary>
 /// UC 2 : Adds the splitPhrase into the map.
 /// </summary>
 /// <param name="splitPhrase">The split phrase.</param>
 /// <param name="mapNode">The map node.</param>
 public static void AddSplitPhraseIntoMap(string[] splitPhrase, MyMapNode <string, string> mapNode)
 {
     Console.WriteLine("Adding KeyValue pair");
     for (int i = 0; i < splitPhrase.Length; i++)
     {
         mapNode.Add($"{i}", splitPhrase[i]);
     }
 }
Beispiel #3
0
 public MyParagraph(string sentence)
 {
     words        = sentence.Split(' ');
     myMapNodeObj = new MyMapNode <int, string>(words.Length);
     foreach (string word in words)
     {
         myMapNodeObj.Add(keyNo, word);
         keyNo++;
     }
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Hash Table Problem!");
            string paragraph = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations";

            string[] para = paragraph.Split(" ");
            MyMapNode <int, string> hash = new MyMapNode <int, string>(para.Length);
            int key = 0;

            foreach (string word in para)
            {
                hash.Add(key, word);
                key++;
            }
            Operation operation = new Operation();

            operation.Frequency(hash);
        }