Ejemplo n.º 1
0
        public void Search()
        {
            var tree = new TTree <int>(1, 1);

            tree.Add(70);
            tree.Add(20);
            tree.Add(10);
            tree.Add(50);
            tree.Add(90);

            Assert.AreEqual(90, tree.Search(90));
            Assert.AreEqual(70, tree.Search(70));
            Assert.AreEqual(50, tree.Search(50));
            Assert.AreEqual(20, tree.Search(20));
            Assert.AreEqual(10, tree.Search(10));
        }
Ejemplo n.º 2
0
        public void CustomSearch()
        {
            var tree = new TTree <string>(1, 1);

            tree.Add("70");
            tree.Add("20");
            tree.Add("10");
            tree.Add("50");
            tree.Add("90");

            Assert.AreEqual("90", tree.Search(90, (x, y) => x.ToString().CompareTo(y)));
            Assert.AreEqual("70", tree.Search(70, (x, y) => x.ToString().CompareTo(y)));
            Assert.AreEqual("50", tree.Search(50, (x, y) => x.ToString().CompareTo(y)));
            Assert.AreEqual("20", tree.Search(20, (x, y) => x.ToString().CompareTo(y)));
            Assert.AreEqual("10", tree.Search(10, (x, y) => x.ToString().CompareTo(y)));
        }
Ejemplo n.º 3
0
        public void CheckThatAllInsertedItemsExist()
        {
            var tree = new TTree <int>(20, 23);

            for (int i = 0; i < 1000; ++i)
            {
                tree.Add(i);
            }

            for (int i = 0; i < 1000; ++i)
            {
                Assert.AreEqual(i, tree.Search(i));
            }
        }
Ejemplo n.º 4
0
        private static void InsertLoop()
        {
            Console.WriteLine("Number of iteration? ");
            int max = int.Parse(Console.ReadLine());

            Console.WriteLine("Tree min order (max = min + 3)?");
            int orderMin = int.Parse(Console.ReadLine());

            TTree <string> root = new TTree <string>(orderMin, orderMin + 3);

            for (int i = 0; i < max; ++i)
            {
                string item = Guid.NewGuid().ToString();
                root.Add(item);
                root.Search(item);
            }
        }