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


C# Tree.Add方法代码示例

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


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

示例1: Main

        static void Main()
        {
            var tree = new Tree<int>();

            tree.Add(13);
            tree.Add(18);
            tree.Add(5);
            tree.Add(20);
            tree.Add(15);
            tree.Add(5);
            tree.Add(9);
            tree.Add(3);
            tree.Add(17);
            tree.Add(10);

            foreach (var item in tree)
            {
                Console.WriteLine("{0}", item);
            }

            tree.Remove(13);

            foreach (var item in tree)
            {
                Console.WriteLine("{0}", item);
            }
        }
开发者ID:NK-Hertz,项目名称:Telerik-Academy-2015,代码行数:27,代码来源:StartUp.cs

示例2: AddingTwo_SmallerGoesToLeft

        public void AddingTwo_SmallerGoesToLeft()
        {
            var t = new Tree<int>();

            t.Add(23);
            t.Add(1);

            Assert.AreEqual(1, t.Root.Left.Item);
        }
开发者ID:alwalker,项目名称:DataStructures,代码行数:9,代码来源:Tests.cs

示例3: AddingTwo_LargerGoesToRight

        public void AddingTwo_LargerGoesToRight()
        {
            var t = new Tree<int>();

            t.Add(23);
            t.Add(78);

            Assert.AreEqual(78, t.Root.Right.Item);
        }
开发者ID:alwalker,项目名称:DataStructures,代码行数:9,代码来源:Tests.cs

示例4: Initialize

 public void Initialize()
 {
     tree = new Tree<int>();
     tree.Add(5);
     tree.Add(2);
     tree.Add(1);
     tree.Add(3);
     tree.Add(4);
 }
开发者ID:NataliaDymnikova,项目名称:Homework,代码行数:9,代码来源:TreeTest.cs

示例5: CheckUnderDirectoriesWithWildcard

        public void CheckUnderDirectoriesWithWildcard()
        {
            var tree = new Tree<bool>();
            tree.Add(@"C:\X", true);
            tree.Add(@"C:\X\*", false);

            Assert.IsTrue(tree.Under(@"C:\X"));
            Assert.IsFalse(tree.Under(@"C:\X\foo"));
            Assert.IsFalse(tree.Under(@"C:\X\1\foo"));
            Assert.IsFalse(tree.Under(@"D:\foo"));
        }
开发者ID:heaths,项目名称:psmsi,代码行数:11,代码来源:TreeTests.cs

示例6: CheckUnderDirectories

        public void CheckUnderDirectories()
        {
            var tree = new Tree<bool>();
            tree.Add(@"C:\A\1", true);
            tree.Add(@"C:\A\2", true);
            tree.Add(@"C:\B", true);
            tree.Add(@"C:\B\1", false);

            Assert.IsTrue(tree.Under(@"C:\A\1\foo"));
            Assert.IsTrue(tree.Under(@"C:\B\2\foo"));
            Assert.IsTrue(tree.Under(@"C:\B"));
            Assert.IsFalse(tree.Under(@"C:\B\1\foo"));
            Assert.IsFalse(tree.Under(@"C:\C\foo"));
            Assert.IsFalse(tree.Under(@"D:\foo"));
        }
开发者ID:heaths,项目名称:psmsi,代码行数:15,代码来源:TreeTests.cs

示例7: getTree

        public Tree getTree( )
        {
            Tree tree = new Tree();

            tree.Key = "Header";
            {

                tree.Add("EngineVersion", this._EngineVersion);
                tree.Add("Owner", this._Owner);
                tree.Add("Version", this._Version);
                tree.Add("Time", this._Time);
                tree.Add("Title", this._Title);
            }

            return tree;
        }
开发者ID:IrisTechnica,项目名称:Iris-Engine,代码行数:16,代码来源:ProjectHeader.cs

示例8: ToString_ReturnsBFSString

 public void ToString_ReturnsBFSString()
 {
     var tree = new Tree<int>();
     tree.Add(3).Add(2).Add(5).Add(4);
     var result = tree.ToString();
     Assert.AreEqual("3 2 5 4 ", result);
 }
开发者ID:gartdan,项目名称:vs2015demos,代码行数:7,代码来源:TreeTests.cs

示例9: CheckCaseSensitiveSentence

        public void CheckCaseSensitiveSentence()
        {
            var tree = new Tree<bool>(new char[] { ' ', ',', '.' }, StringComparer.Ordinal);
            tree.Add("The quick brown fox jumps.", true);

            Assert.IsTrue(tree.Under("The quick brown fox jumps over the lazy dog."));
            Assert.IsFalse(tree.Under("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."));
            Assert.IsFalse(tree.Under("A different sentence."));
        }
开发者ID:heaths,项目名称:psmsi,代码行数:9,代码来源:TreeTests.cs

示例10: Main

        static void Main()
        {
            Tree<int> tree = new Tree<int>(10);

            for (int i = 0; i < 20; i++)
            {
                if (i == 10) i++;
                tree.Add(i);
            }

            Console.WriteLine(tree);
            Console.WriteLine(tree.HasValue(15));
            Console.WriteLine(tree.HasValue(25));

            tree.Add(25);
            Console.WriteLine(tree);
            Console.WriteLine(tree.HasValue(25));
        }
开发者ID:RuzmanovDev,项目名称:TelerikAcademy,代码行数:18,代码来源:TestTree.cs

示例11: Main

        static void Main(string[] args)
        {
            var tree = new Tree<int>();
            tree.Add(30).Add(25).Add(36).Add(12).Add(5);
            Console.WriteLine($"There are {tree.Count} elements in the tree");
            ITreeBuilder<int> builder = new IntTreeBuilder();
            var largeTree = builder.Build(1000000);

            Console.WriteLine($"There are {largeTree.Count} elements in the large tree");
        }
开发者ID:gartdan,项目名称:vs2015demos,代码行数:10,代码来源:Program.cs

示例12: MakeRows

 void MakeRows(Tree<Cell> table)
 {
     do {
         var row = makeTreeCell(string.Empty);
         row.Value.SetAttribute(CellAttribute.StartTag, startTags[1]);
         row.Value.SetAttribute(CellAttribute.EndTag, endTags[1]);
         table.Add(row);
         MakeCells(row);
         if (scanner.Current.Type == TokenType.Newline) scanner.MoveNext();
     } while (scanner.Current.Type == TokenType.BeginCell || scanner.Current.Type == TokenType.Word);
 }
开发者ID:jediwhale,项目名称:fitsharp,代码行数:11,代码来源:TextTables.cs

示例13: EnumerateWithNoChildren

 public void EnumerateWithNoChildren()
 {
     var tree = new Tree<int>(7, EnumeratorOrder.DepthFirstSearch);
     Assert.AreEqual(7, tree.AsEnumerable().First());
     tree.Order = EnumeratorOrder.BreadthFirstSearch;
     Assert.AreEqual(7, tree.AsEnumerable().First());
     var subtree = new Tree<int>(5, EnumeratorOrder.BreadthFirstSearch);
     tree.Add(subtree);
     Assert.AreEqual(5, tree.AsEnumerable().Last());
     tree.Order = EnumeratorOrder.DepthFirstSearch;
     Assert.AreEqual(5, tree.AsEnumerable().Last());
 }
开发者ID:karolbilicki,项目名称:Exercises,代码行数:12,代码来源:Tests.cs

示例14: BuildTree

        private static Tree BuildTree(IEnumerable<Type> types, string rootName)
        {
            var nodeFactory = new NodeFactory();
            var tree = new Tree(nodeFactory, rootName);

            foreach (var type in types)
            {
                var fullName = type.FullName;
                tree.Add(fullName);
            }
            return tree;
        }
开发者ID:jklipp,项目名称:codegravity,代码行数:12,代码来源:Analyzer.cs

示例15: AddSurplusRow

 void AddSurplusRow(object surplusValue, Tree<Cell> table) {
     var cells = new List<Tree<Cell>>();
     foreach (var actualValue in strategy.ActualValues(surplusValue)) {
         var cell = processor.Compose(actualValue.IsVoid ? new TypedValue(string.Empty) : actualValue);
         if (cells.Count == 0) {
             cell.Value.SetAttribute(CellAttribute.Label, "surplus");
         }
         cells.Add(cell);
     }
     var row = processor.MakeCell(string.Empty, "tr", cells);
     processor.TestStatus.MarkWrong(row.Value);
     table.Add(row);
 }
开发者ID:GibSral,项目名称:fitsharp,代码行数:13,代码来源:ListMatcher.cs


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