public void AddingAndDeletingElementByHash2Test() { IHashFunction hash = new Hash2(); HashTable hashTable = new HashTable(hash); hashTable.AddValue("ghj"); hashTable.AddValue("wer"); hashTable.DeleteValue("ghj"); Assert.IsFalse(hashTable.HashContains("ghj")); Assert.IsTrue(hashTable.HashContains("wer")); }
public void ChangeHashFunctionTest() { IHashFunction hash = new Hash2(); HashTable hashTable = new HashTable(hash); hashTable.AddValue("asd"); hashTable.AddValue("vbn"); IHashFunction newHash = new Hash1(); hashTable.ChangeHashFunction(newHash); hashTable.AddValue("abn"); hashTable.DeleteValue("vbn"); Assert.IsTrue(hashTable.HashContains("abn")); Assert.IsTrue(hashTable.HashContains("asd")); Assert.IsFalse(hashTable.HashContains("vbn")); }
static void Main(string[] args) { var hashTable = new HashTable(); hashTable.AddValue("123"); Console.WriteLine("hashTable.AddValue(\"123\")"); Console.WriteLine($"hashTable.Contains(\"123\"): {hashTable.Contains("123")}"); Console.WriteLine(); hashTable.DeleteValue("123"); Console.WriteLine("hashTable.DeleteValue(\"123\")"); Console.WriteLine($"hashTable.Contains(\"123\"): {hashTable.Contains("123")}"); Console.WriteLine(); hashTable.AddValue("123"); Console.WriteLine("hashTable.AddValue(\"123\")"); hashTable.Clear(); Console.WriteLine("hashTable.Clear()"); Console.WriteLine($"hashTable.Contains(\"123\"): {hashTable.Contains("123")}"); }