예제 #1
0
        public void Point_Contains_CustomBinaryTree()
        {
            var comparer = new PointComparator();

            var newTree = new BinarySearchTree <Point>(inputArray, comparer);

            Assert.IsTrue(newTree.Contains(inputArray[0]));

            Assert.IsFalse(newTree.Contains(new Point(12.0, 5.0)));
        }
예제 #2
0
        public void Point_Inorder_CustomBinaryTree_With_IComparer()
        {
            var comparer = new PointComparator();

            var newTree = new BinarySearchTree <Point>(comparer);

            newTree.Add(inputArray);

            var helperArrayResult = new Point[3] {
                inputArray[2], inputArray[0], inputArray[1]
            };

            var index = 0;

            foreach (Point item in newTree.Inorder())
            {
                Assert.AreEqual(helperArrayResult[index++], item);
            }
        }
예제 #3
0
        public void Point_Preorder_CustomBinaryTree_With_Comparison()
        {
            var comparer = new PointComparator();

            Comparison <Point> comparison = comparer.Compare;

            var newTree = new BinarySearchTree <Point>(comparison);

            newTree.Add(inputArray);

            var helperArrayResult = new Point[3] {
                inputArray[0], inputArray[2], inputArray[1]
            };

            var index = 0;

            foreach (Point item in newTree)
            {
                Assert.AreEqual(helperArrayResult[index], item);

                index++;
            }
        }