public static double TimeInputForHashST(HashTableOptions options) { var file = File.OpenRead("tale.txt"); Scanner scanner = new Scanner(new StreamReader(file)); StopWatch stopWatch = new StopWatch(); IHashTable <string, int> hashTable = options switch { HashTableOptions.LinearProbiningHash => new LinearProbingHashST <string, int>(), HashTableOptions.SeparateChainingHash => new SeparateChainingHashST <string, int>(), _ => throw new Exception("Cannot find the options") }; while (scanner.HasNext()) { var word = scanner.Read(); hashTable.Put(word, hashTable.Get(word) + 1); } double time = stopWatch.ElapsedTime; return(time); }
public void HashTable_Add_AddToEmptyHashTable_Successful() { _ht.Add(1, "one"); Assert.AreEqual("one", _ht.Get(1)); }
static public V Search(IHashTable <K, V> ht, K key) { return(ht.Get(key)); }
public void Test_GetByPerson_Null_NullRef_Exc() { Assert.Throws <NullReferenceException>(() => ht.Get(null)); }