當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。