当前位置: 首页>>代码示例>>C#>>正文


C# BinarySearchTree.BreadthFirstSearchEnumerator方法代码示例

本文整理汇总了C#中BinarySearchTree.BreadthFirstSearchEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySearchTree.BreadthFirstSearchEnumerator方法的具体用法?C# BinarySearchTree.BreadthFirstSearchEnumerator怎么用?C# BinarySearchTree.BreadthFirstSearchEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinarySearchTree的用法示例。


在下文中一共展示了BinarySearchTree.BreadthFirstSearchEnumerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanEnumerateBreadthFirstSearch

        public void CanEnumerateBreadthFirstSearch()
        {
            var tree = new BinarySearchTree<int, int>(new[] {3, 2, 1, 2, 4, 3}.AsKeyValueList());

            var expected = new[] {3, 2, 4, 1, 2, 3};
            CollectionAssert.AreEqual(expected, tree.BreadthFirstSearchEnumerator().Select(_ => _.Value).ToList());
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:7,代码来源:WhenEnumeratingTree.cs

示例2: AppearInRootAfterAddingFirstElement

        public void AppearInRootAfterAddingFirstElement()
        {
            var tree = new BinarySearchTree<int, int>();
            var element = 1.AsKeyValue();
            tree.Insert(element);

            Assert.IsTrue(tree.BreadthFirstSearchEnumerator().Contains(element));
            Assert.IsTrue(tree.DepthFirstSearchEnumerator().Contains(element));
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:9,代码来源:WhenAddingElement.cs

示例3: CanDeleteFromMiddleWithRightChild

        public void CanDeleteFromMiddleWithRightChild()
        {
            var tree = new BinarySearchTree<int, int>();
            tree.Insert(1.AsKeyValue());
            tree.Insert(2.AsKeyValue());
            tree.Insert(3.AsKeyValue());

            tree.Delete(2);

            CollectionAssert.AreEqual(new[] {1, 3}, tree.BreadthFirstSearchEnumerator().Select(_ => _.Value).ToList());
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:11,代码来源:WhenDeletingNode.cs

示例4: CanDeleteFromLeftLeaf

        public void CanDeleteFromLeftLeaf()
        {
            var tree = new BinarySearchTree<int, int>();
            tree.Insert(3.AsKeyValue());
            tree.Insert(2.AsKeyValue());
            tree.Insert(1.AsKeyValue());

            tree.Delete(1);

            CollectionAssert.AreEqual(new[] {3, 2}, tree.BreadthFirstSearchEnumerator().Select(_ => _.Value).ToList());
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:11,代码来源:WhenDeletingNode.cs

示例5: CountInEnumeratorsMustMatchCountInTree

        public void CountInEnumeratorsMustMatchCountInTree()
        {
            var tree = new BinarySearchTree<int, int>();

            tree.Insert(1.AsKeyValue());
            tree.Insert(3.AsKeyValue());
            tree.Insert(2.AsKeyValue());

            Assert.AreEqual(3, tree.BreadthFirstSearchEnumerator().Count());
            Assert.AreEqual(3, tree.DepthFirstSearchEnumerator().Count());
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:11,代码来源:WhenEnumeratingTree.cs

示例6: AppearInBinarySerachTreeOrder

        public void AppearInBinarySerachTreeOrder()
        {
            var tree = new BinarySearchTree<int, int>();
            var element1 = 1.AsKeyValue();
            var element2 = 2.AsKeyValue();
            var element3 = 3.AsKeyValue();
            tree.Insert(element2);
            tree.Insert(element3);
            tree.Insert(element1);

            var elements = tree.BreadthFirstSearchEnumerator();
            Assert.AreEqual(elements.ElementAt(0), element2);
            Assert.AreEqual(elements.ElementAt(1), element1);
            Assert.AreEqual(elements.ElementAt(2), element3);
        }
开发者ID:marat-turaev,项目名称:BinarySearchTree,代码行数:15,代码来源:WhenAddingElement.cs


注:本文中的BinarySearchTree.BreadthFirstSearchEnumerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。