コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void ExceptionNullVisitor()
        {
            var tree = new BinarySearchTree <int, string>();

            tree.AcceptVisitor(null);
        }
コード例 #4
0
ファイル: Accept.cs プロジェクト: havok/ngenerics
 public void ExceptionNullVisitor()
 {
     var tree = new BinarySearchTree<int, string>();
     tree.AcceptVisitor(null);
 }
コード例 #5
0
        public void ExceptionNullVisitor()
        {
            var tree = new BinarySearchTree <int, string>();

            Assert.Throws <ArgumentNullException>(() => tree.AcceptVisitor(null));
        }