public void TestAddingTheSameElement() { var table = new HashTable(2); table.PutPair("Pushkin", "The captain's daughter"); table.PutPair("Pushkin", "Dubrovsky"); Assert.AreEqual("Dubrovsky", table.GetValueByKey("Pushkin")); }
static object SimilarKeysTest() { var table = new HashTable(1); table.PutPair("se4f", 575287); table.PutPair("se4f", 123); return((int)table.GetValueByKey("se4f") == 123); }
static object ThreeElementsTest() { var table = new HashTable(3); table.PutPair("3434", 13424); table.PutPair("ghhh", 51977); table.PutPair("12", 59498); return((int)table.GetValueByKey("ghhh") == 51977); }
public void TestThreeElements() { var table = new HashTable(3); table.PutPair("Pushkin", "The captain's daughter"); table.PutPair("Lermontov", "A hero of our time"); table.PutPair("Tolstoy", "War and peace"); Assert.AreEqual("The captain's daughter", table.GetValueByKey("Pushkin")); Assert.AreEqual("A hero of our time", table.GetValueByKey("Lermontov")); Assert.AreEqual("War and peace", table.GetValueByKey("Tolstoy")); }
static object HugeAndOneFindTest() { var tbl = new HashTable(10000); for (var i = 1; i <= tbl.Length; i++) { tbl.PutPair(i, i); } return((int)tbl.GetValueByKey(100) == 100); }
public void TestSearchingOneElement() { var rnd = new Random(); var table = new HashTable(10000); var toFindKey = RandomString(10); var toFindValue = RandomString(10); var put = rnd.Next(0, 1000); for (int i = 0; i < 10000; i++) { if (i == put) { table.PutPair(toFindKey, toFindValue); } else { table.PutPair(RandomString(5), RandomString(5)); } } Assert.AreEqual(toFindValue, table.GetValueByKey(toFindKey)); }
public void TestSearching() { var table = new HashTable(10000); for (int i = 0; i < 10000; i++) { table.PutPair(RandomString(10), RandomString(10)); } for (int i = 0; i < 1000; i++) { Assert.AreEqual(null, table.GetValueByKey(i)); } }
static object HugeAndFadedFindTest() { var tbl = new HashTable(1500000); for (var i = 1; i <= tbl.Length; i++) { tbl.PutPair(i, i * 2); } for (var i = tbl.Length + 1; i <= (tbl.Length * 1.1); i++) { if ((object)tbl.GetValueByKey(i) != null) { return(false); } } return(true); }