Esempio n. 1
0
        public void InsertIsWorking()
        {
            HashTabl <int, int> t = new HashTabl <int, int>();
            Random r = new Random();

            for (int i = 0; i < 1000; i++)
            {
                t.Insert(r.Next(0, 10000), r.Next(0, 1000000));
                Assert.AreEqual(i + 1, t.Count);
            }
        }
Esempio n. 2
0
        void ChangeCapacity()
        {
            HashTabl <TKey, TValue> temp = new HashTabl <TKey, TValue>(Capacity * 4);

            foreach (var t in table)
            {
                if (t == null)
                {
                    continue;
                }
                temp.Insert(t.key, t.value);
            }
            table  = temp.table;
            _count = temp._count;
        }
Esempio n. 3
0
        public void DeleteIsWorking()
        {
            HashTabl <int, int> t = new HashTabl <int, int>();

            for (int i = 0; i < 1000; i++)
            {
                t.Insert(i + 1, i + 10000); // 1 - 1000, 10001-110000
            }
            int counter = 1000;

            for (int i = 1000; i > 0; i--)
            {
                t.Delete(i, i + 10000);
                Assert.AreEqual(counter--, t.Count);
            }
        }
Esempio n. 4
0
        public void SearchNElseWorking()
        {
            HashTabl <int, int> t = new HashTabl <int, int>();

            for (int i = 0; i < 100; i++)
            {
                t.Insert(i + 1, i + 10000); // 1 - 100, 10001-10100
            }

            for (int i = 0; i < 100; i++)
            {
                int temp = t.Search(i + 1);
                Assert.AreEqual(i + 10000, temp);
                //t.Delete(i + 1, i + 10000);
                //temp = t.Search(i + 1);
                //Assert.AreEqual(0, temp);
            }
        }