static void Main(string[] args) { Console.WriteLine("Hello Welcome to My HashTable Application BY AMIT RANA"); /* MyMapNode<int, string> hash = new MyMapNode<int, string>(6); * 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 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); operation.Remove(hash, "are"); }
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"); } } }
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}"); } }