using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HashImpplementation { public class HashEntry { public HashEntry(K key,V value) { this.Key = key; this.Value = value; } public K Key { get; set; } public V Value { get; set; } } } /////////////////////////////////////////// using HashImpplementation; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dictionary { public class HashTable { private int maxSize = 64; private List> table; private int Hash(K key) { int index = 7; int asciiVal = 0; for (int i = 0; i >(); } public void Insert(HashEntry items) { int hashVal = Hash(items.Key); table.Add(items); //table[hashVal].Add(new HashEntry(key,value)); } public V Get(K key) { int hashVal = Hash(key); // linq HashEntry result = table.FirstOrDefault(x => x.Key.Equals(key)); return result.Value; /// List> allEntryes = table[hashVal]; /* foreach (HashEntry entry in allEntryes) { if (entry.Key.Equals(key)) { return entry.Value; } } return default(V);*/ } } } /////////////////////////////////////// using HashImpplementation; using System; namespace Dictionary { class Program { static void Main(string[] args) { HashTable notes = new HashTable(5); HashEntry items = new HashEntry("Boby", 25); HashEntry items2 = new HashEntry("Even", 27); HashEntry items3 = new HashEntry("Billy", 29); HashEntry items5 = new HashEntry("Jack", 12); HashEntry items6 = new HashEntry("Alex", 34); notes.Insert(items); notes.Insert(items2); notes.Insert(items3); notes.Insert(items5); notes.Insert(items6); Console.WriteLine(notes.Get("Even")); } } }