Esempio n. 1
0
        public void CanGetEntryFromHashTable()
        {
            var sut = new SeparateChainingHashTable <string, int>();

            sut.Add("One", 1);
            Assert.True(sut.Find("One"));
        }
Esempio n. 2
0
        public void SeparateChainingMaintenanceHashTable()
        {
            var sut = new SeparateChainingHashTable <string, int>(100000);

            for (var i = 0; i < 100000; i++)
            {
                sut.Add(i.ToString(CultureInfo.InvariantCulture), i);
            }
            for (var i = 0; i < 100000; i++)
            {
                Assert.Equal(i, sut.Get(i.ToString(CultureInfo.InvariantCulture)));
            }
            for (var i = 0; i < 100000; i++)
            {
                sut.Add(i.ToString(CultureInfo.InvariantCulture), i * 2);
            }
            for (var i = 0; i < 100000; i++)
            {
                Assert.Equal(i * 2, sut.Get(i.ToString(CultureInfo.InvariantCulture)));
            }
            for (var i = 0; i < 100000; i++)
            {
                sut.Delete(i.ToString(CultureInfo.InvariantCulture));
            }
            for (var i = 0; i < 100000; i++)
            {
                Assert.False(sut.Find(i.ToString(CultureInfo.InvariantCulture)));
            }
        }
Esempio n. 3
0
        public void FindForNonExistingEntryReturnFalse()
        {
            var sut = new SeparateChainingHashTable <string, int>();

            sut.Add("One", 1);
            Assert.False(sut.Find("Two"));
        }