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


C# BinarySearchTree.GetEnumerator方法代码示例

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


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

示例1: NonIComparable

        public void NonIComparable()
        {
            var tree = new BinarySearchTree<NonComparableTClass, string>
                           {
                               {new NonComparableTClass(4), "4"},
                               {new NonComparableTClass(6), "6"},
                               {new NonComparableTClass(2), "2"},
                               {new NonComparableTClass(5), "5"},
                               {new NonComparableTClass(19), "19"},
                               {new NonComparableTClass(1), "1"}
                           };
            var newTree = SerializeUtil.BinarySerializeDeserialize(tree);

            Assert.AreNotSame(tree, newTree);
            Assert.AreEqual(tree.Count, newTree.Count);

            var treeEnumerator = tree.GetEnumerator();
            var newTreeEnumerator = newTree.GetEnumerator();

            while (treeEnumerator.MoveNext())
            {
                Assert.IsTrue(newTreeEnumerator.MoveNext());
                Assert.AreEqual(treeEnumerator.Current.Key.Number, newTreeEnumerator.Current.Key.Number);
                Assert.AreEqual(treeEnumerator.Current.Value, newTreeEnumerator.Current.Value);

                Assert.IsTrue(newTree.ContainsKey(treeEnumerator.Current.Key));
                Assert.AreEqual(newTree[treeEnumerator.Current.Key], treeEnumerator.Current.Value);
            }

            Assert.IsFalse(newTreeEnumerator.MoveNext());
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:31,代码来源:Serializability.cs

示例2: Enumerate

        public void Enumerate()
        {
            var tree = new BinarySearchTree<int>() { -1, 0, 1 };
              var itr = tree.GetEnumerator();
              var actual = new List<int>();

              while (itr.MoveNext())
            actual.Add(itr.Current);

              CollectionAssert.AreEquivalent(new int[] { -1, 0, 1 }, actual);
        }
开发者ID:andrewboudreau,项目名称:data-structures-and-algorithms,代码行数:11,代码来源:TraversalTest.cs

示例3: InsertTest

        public void InsertTest([PexAssumeUnderTest]int[] newElements)
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int>(newElements);

            PexAssert.AreEqual(newElements.Length, bst.Count);
            PexAssert.IsNotNull(bst.GetEnumerator());
            PexAssert.IsNotNull(bst.GetPostorderEnumerator());
            PexAssert.IsNotNull(bst.GetInorderEnumerator());
            PexAssert.IsNotNull(bst.GetBreadthFirstEnumerator());
            PexObserve.ValueForViewing<int[]>("newElements", newElements);
            PexObserve.ValueForViewing<int[]>("Constructed tree", bst.ToArray());
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:12,代码来源:BinarySearchTreeTest.cs

示例4: GetEnumeratorGenericTest

        public void GetEnumeratorGenericTest()
        {
            BinarySearchTree<int> bst = new BinarySearchTree<int> {10, 5, 3, 8, 12, 11};

            Assert.IsNotNull(bst.GetEnumerator());
        }
开发者ID:taoxiease,项目名称:asegrp,代码行数:6,代码来源:BinarySearchTreeTest.cs

示例5: GetEnumeratorExample

        public void GetEnumeratorExample()
        {
            BinarySearchTreeBase<string, int> tree = new BinarySearchTree<string, int>
                                                         {
                                                             new KeyValuePair<string, int>("cat", 1),
                                                             new KeyValuePair<string, int>("dog", 2),
                                                             new KeyValuePair<string, int>("canary", 3)
                                                         };

            var enumerator = tree.GetEnumerator();

            // Enumerate through the items in the tree, and write the contents
            // to the standard output.
            while (enumerator.MoveNext())
            {
                Console.Write("Key : ");
                Console.WriteLine(enumerator.Current.Key);
                Console.Write("Value : ");
                Console.WriteLine(enumerator.Current.Value);
            }
        }
开发者ID:havok,项目名称:ngenerics,代码行数:21,代码来源:BinarySearchTreeBaseExamples.cs


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