Example #1
0
        static void Main(string[] args)
        {
            //Linear<Person, Person> linear = new Linear<Person, Person>();
            //Quadratic<Person, Person> quad = new Quadratic<Person, Person>();
            //DoubleHash<Person, Person> dh = new DoubleHash<Person, Person>();

            //TestHT(linear);
            //TestHT(quad);
            //TestHT(dh);

            ChainingHT <int, string> cht = new ChainingHT <int, string>();

            // right now the Add() method also handles expanding,
            //  this is fine since we know that both Add() works, and ExpandHashtable() works
            //TestAdd(cht);
            //TestGet(cht);
            //TestRemove(cht);
            TestChainingHT(cht);
            //Console.WriteLine(cht.ToString());



            //TestAdd(ht);
            //Console.WriteLine(ht.ToString());
            //TestExpand(ht);
            //Console.WriteLine(ht.ToString());
            //TestRemove(ht);
            //Console.WriteLine(ht.ToString());
            //TestGet(ht);
        }
Example #2
0
        static void TestChainingHT(ChainingHT <int, string> cht)
        {
            //Test the ChainingHT by addeding 100000 elements to the table
            long start;
            long end;

            //BST<int> balanceTree = new BST<int>();
            start = Environment.TickCount;
            Random randomNumber = new Random((int)start);
            int    iMax         = 100000;
            int    iLargest     = iMax * 10;

            for (int i = 0; i < iMax; i++)
            {
                cht.Add(randomNumber.Next(i, iLargest), "test");
            }
            end = Environment.TickCount;

            Console.WriteLine("Time to add: " + (end - start).ToString() + " ms");
        }