コード例 #1
0
ファイル: Program.cs プロジェクト: Ruthikreddy/HashTable
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to HashTables");
            MyMapNode <string, string> mapNode = new MyMapNode <string, string>(5);

            Console.WriteLine("Adding KeyValue pair");
            mapNode.Add("0", "Paranoids");
            mapNode.Add("1", "are");
            mapNode.Add("2", "not");
            mapNode.Add("3", "paranoid");
            mapNode.Add("4", "beacuse");
            mapNode.Add("5", "they");
            mapNode.Add("6", "are");
            mapNode.Add("7", "paranoid");
            mapNode.Add("8", "but");
            mapNode.Add("9", "because");
            mapNode.Add("10", "they");
            mapNode.Add("12", "putting");
            mapNode.Add("13", "themselves");
            mapNode.Add("14", "deliberately");
            mapNode.Add("15", "into");
            mapNode.Add("16", "paranoid");
            mapNode.Add("17", "avoidable");
            mapNode.Add("18", "situations");
            mapNode.GetFreq("paranoid");
            mapNode.DisplayFrequency();
            mapNode.RemoveValue("avoidable");
            mapNode.GetFreq("avoidable");
        }
コード例 #2
0
 public void Remove(MyMapNode <int, string> hash, string word)
 {
     for (int key = 0; key < hash.size; key++)
     {
         if (hash.Get(key).Equals(word))
         {
             hash.Remove(key);
             Console.WriteLine($"Removed {word} from paragraph");
         }
     }
 }
コード例 #3
0
 public void Frequency(MyMapNode <int, string> hash)
 {
     for (int key = 0; key < hash.size; key++)
     {
         frequency.TryAdd(hash.Get(key).ToLower(), 0);
         frequency[hash.Get(key).ToLower()]++;
     }
     foreach (KeyValuePair <string, int> item in frequency)
     {
         Console.WriteLine($"frequency of word '{item.Key}' is {item.Value}");
     }
 }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to C# Hash Tables!");
            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");

            Console.WriteLine("5th index : " + hash.Get("5"));
        }
コード例 #5
0
        static void Main(string[] args)
        {
            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.Remove(hash, "avoidable");
        }