public void AcceptVisitorExample() { BinarySearchTreeBase<string, int> tree = new BinarySearchTree<string, int> { {"cat", 1}, {"dog", 2}, {"canary", 3} }; // There should be 3 items in the tree. Assert.AreEqual(3, tree.Count); // Create a visitor that will simply count the items in the tree. var visitor = new CountingVisitor<KeyValuePair<string, int>>(); // Make the tree call IVisitor<T>.Visit on all items contained. tree.AcceptVisitor(visitor); // The counting visitor would have visited 3 items. Assert.AreEqual(3, visitor.Count); }
public void AcceptVisitorExample() { BinarySearchTreeBase <string, int> tree = new BinarySearchTree <string, int> { { "cat", 1 }, { "dog", 2 }, { "canary", 3 } }; // There should be 3 items in the tree. Assert.AreEqual(3, tree.Count); // Create a visitor that will simply count the items in the tree. var visitor = new CountingVisitor <KeyValuePair <string, int> >(); // Make the tree call IVisitor<T>.Visit on all items contained. tree.AcceptVisitor(visitor); // The counting visitor would have visited 3 items. Assert.AreEqual(3, visitor.Count); }
public void ExceptionNullVisitor() { var tree = new BinarySearchTree <int, string>(); tree.AcceptVisitor(null); }
public void ExceptionNullVisitor() { var tree = new BinarySearchTree<int, string>(); tree.AcceptVisitor(null); }
public void ExceptionNullVisitor() { var tree = new BinarySearchTree <int, string>(); Assert.Throws <ArgumentNullException>(() => tree.AcceptVisitor(null)); }