static void TestLPHash() { LPHash <int, int> hash = new LPHash <int, int>(); var random = new Random(); Stopwatch watch = new Stopwatch(); watch.Restart(); var find = random.Next(0, 10000); hash.Add(find, find); int toAdd; for (int i = 0; i < 10000; i++) { toAdd = random.Next(0, 10000); hash.Add(toAdd, toAdd); } Console.WriteLine("LPHash: " + watch.ElapsedMilliseconds); Console.WriteLine("Find: " + 5000 + " in LPHash"); int result = 0; bool success = false; watch.Restart(); success = hash.Get(5000, ref result); Console.WriteLine("Find: " + result + " success: " + success + " in: " + watch.ElapsedTicks); }
private void Resize(int p_size) { var temp = new LPHash <Key, Value>(p_size); for (int i = 0; i < size; i++) { if (!tables[i].IsEmpty) { temp.Add(tables[i].key, tables[i].value); } } tables = temp.tables; number = temp.number; size = temp.size; }