コード例 #1
0
        public void SearchingOneElement()
        {
            var rnd         = new Random();
            var List        = new HashTableList(10000);
            var toFindKey   = RandomString(10);
            var toFindValue = RandomString(10);
            var put         = rnd.Next(0, 1000);

            for (int i = 0; i < 10000; i++)
            {
                if (i == put)
                {
                    List.PutPair(toFindKey, toFindValue);
                }
                else
                {
                    List.PutPair(RandomString(5), RandomString(5));
                }
            }
            Assert.AreEqual(toFindValue, List.GetValueByKey(toFindKey));
            for (int i = 1; i < 10000; i++)
            {
                List.PutPair(RandomString(10), RandomString(10));
            }
            Assert.AreEqual(toFindValue, List.GetValueByKey(toFindKey));
        }
コード例 #2
0
        public void ThreeElements()
        {
            var List = new HashTableList(3);

            List.PutPair("BMW", "E39");
            List.PutPair("Audi", "A6");
            List.PutPair("JDM", "Tourer V");

            Assert.AreEqual("E39", List.GetValueByKey("BMW"));
            Assert.AreEqual("A6", List.GetValueByKey("Audi"));
            Assert.AreEqual("Tourer V", List.GetValueByKey("JDM"));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: veetash/Hash
        static void Main(string[] args)
        {
            var List = new HashTableList(3);

            List.PutPair("BMW", "E39");
            List.PutPair("Audi", "A6");
            List.PutPair("JDM", "Tourer V");
            List.PutPair("Mercedes", "V-klasse");
            List.PutPair("BMW", "M5");

            Console.WriteLine(List.GetValueByKey("Mercedes"));
            Console.WriteLine(List.GetValueByKey("BMW"));
            Console.WriteLine(List.GetValueByKey("Audi"));
            Console.WriteLine(List.GetValueByKey("JDM"));
        }
コード例 #4
0
        public void AddingTheSameElement()
        {
            var List = new HashTableList(2);

            List.PutPair("BMW", "E39");
            List.PutPair("BMW", "M5");

            Assert.AreEqual("M5", List.GetValueByKey("BMW"));
        }