本文整理匯總了C#中BinarySearchTree.DepthFirstSearchEnumerator方法的典型用法代碼示例。如果您正苦於以下問題:C# BinarySearchTree.DepthFirstSearchEnumerator方法的具體用法?C# BinarySearchTree.DepthFirstSearchEnumerator怎麽用?C# BinarySearchTree.DepthFirstSearchEnumerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BinarySearchTree
的用法示例。
在下文中一共展示了BinarySearchTree.DepthFirstSearchEnumerator方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CanEnumerateDepthFirstSearch
public void CanEnumerateDepthFirstSearch()
{
var tree = new BinarySearchTree<int, int>(new[] {3, 2, 1, 2, 4, 3}.AsKeyValueList());
var expected = new[] {3, 2, 1, 2, 4, 3};
CollectionAssert.AreEqual(expected, tree.DepthFirstSearchEnumerator().Select(_ => _.Value).ToList());
}
示例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));
}
示例3: 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());
}