Ejemplo n.º 1
0
        static void TestDelete(Hash_DoubleHashing <int, string> h)
        {
            if (h.Count < 1)
            {
                Console.WriteLine("Empty Table!");
                return;
            }
            int deleteAmount = GetNum("How many to delete => ");

            Console.WriteLine();
            for (int i = 0; i < deleteAmount; i++)
            {
                int key = GetNum("Key to delete => ");
                if (h.Delete(key, out string deletedValue))
                {
                    Console.WriteLine($"Key => {key} was deleted deleted value => {deletedValue}");
                }
                else
                {
                    Console.WriteLine($"Key not found => {key}");
                    i--;
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        static void Test2()
        {
            Hash_DoubleHashing <int, string> h = new Hash_DoubleHashing <int, string>(3) //should be size 5
            {
                { 1, "1" },
                { 6, "6" }
            };

            h.Delete(1, out string _);
            h.Add(1, "1");
        }
Ejemplo n.º 3
0
        static void Test1()
        {
            Hash_DoubleHashing <int, string> h = new Hash_DoubleHashing <int, string>(4); //should be size 5

            h.Add(1, "1");
            h.Add(6, "6"); //should step over 1
            h.Delete(1, out string _);
            try
            {
                h.Add(6, "6"); //should fail
            }
            catch (Exception)
            {
                Console.WriteLine("Test Successful!");
                return;
            }
            Console.WriteLine("Test Failed!");
        }