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


C# Tree类代码示例

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


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

示例1: visit

        public override void visit(Tree.MethodDefinition that)
        {
            // TODO: virtual, abstract methods
            var name = that.getIdentifier().getToken().getText().CSharpMethodName();

            base.visit(that);
        }
开发者ID:palad1,项目名称:ceylon-dotnet,代码行数:7,代码来源:RoslynCodeVisitor.cs

示例2: PopulateTree

		public override void PopulateTree (Tree tree)
		{
			XPathNavigator n = new XPathDocument (Path.Combine (basedir, "toc.xml")).CreateNavigator ();
			n.MoveToRoot ();
			n.MoveToFirstChild ();
			PopulateNode (n.SelectChildren ("node", ""), tree.RootNode);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:ecmaspec-provider.cs

示例3: Import

        public int Import(string filePath, int ownerId)
        {
            //Create GEDCOM Store
            var treeName = Path.GetFileNameWithoutExtension(filePath);
            var store = new GEDCOMStore(filePath);

            var treeService = _serviceFactory.CreateTreeService();

            var tree = new Tree() { Name = treeName, OwnerId = ownerId};
            treeService.Add(tree);

            _repositoryLookup = new Dictionary<int, int>();

            //Add Repositories
            ProcessRepositories(store.Repositories, tree.TreeId);

            _sourceLookup = new Dictionary<int, int>();

            //Add Sources
            ProcessSources(store.Sources, tree.TreeId);

            _individualLookup = new Dictionary<int, int>();

            //Add Individuals
            ProcessIndividuals(store.Individuals, tree.TreeId);

            //Add Families
            ProcessFamilies(store.Families, tree.TreeId);

            return tree.TreeId;
        }
开发者ID:mesutc,项目名称:FamilyTreeProject.Dnn,代码行数:31,代码来源:GEDCOMImporter.cs

示例4: RepresentativeTable

        // Constructor for creating a new representative table. We directly fill the table depending on the given sequence.
        public RepresentativeTable(Graph graph, Tree tree)
        {
            // Initialize the table
            _table = new Dictionary<BitSet, RepresentativeList>();

            Queue<BitSet> queue = new Queue<BitSet>();
            queue.Enqueue(tree.Root);
            _table[new BitSet(0, graph.Size)] = new RepresentativeList();

            int i = 0;

            while (queue.Count != 0)
            {
                BitSet node = queue.Dequeue();

                FillTable(graph, node);
                FillTable(graph, graph.Vertices - node);

                if (tree.LeftChild.ContainsKey(node))
                {
                    queue.Enqueue(tree.LeftChild[node]);
                }
                if (tree.RightChild.ContainsKey(node))
                {
                    queue.Enqueue(tree.RightChild[node]);
                }
            }
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:29,代码来源:RepresentativeTable.cs

示例5: Evaluate

        public override sealed double Evaluate(Tree<SyntaxToken> tree, EvaluationContext context)
        {
            var leaf = tree.Leafs[0];
            double value = leaf.Value.Evaluate(leaf, context);

            return Evaluate(value);
        }
开发者ID:bashis,项目名称:MyGraphic,代码行数:7,代码来源:UnaryOpSyntaxToken.cs

示例6: WriteTable

        public void WriteTable(Tree<Cell> table) {
            var tableResult = processor.ParseTree<Cell, StoryTableString>(table).ToString();
            if (string.IsNullOrEmpty(tableResult)) return;

            HandleTableResult(tableResult);
            writesTables = true;
        }
开发者ID:GibSral,项目名称:fitsharp,代码行数:7,代码来源:StoryTestStringWriter.cs

示例7: TransformTree

 public Tree TransformTree(Tree t)
 {
     TregexMatcher matcher = TregexMonthYear.Matcher(t);
     while (matcher.Find())
     {
         Tree root = matcher.GetNode("root");
         Tree month = matcher.GetNode("month");
         Tree year = matcher.GetNode("year");
         var children = new Tree[] {month, year};
         root.SetChildren(children);
         matcher = TregexMonthYear.Matcher(t);
     }
     matcher = TregexMonthDayYear.Matcher(t);
     while (matcher.Find())
     {
         Tree root = matcher.GetNode("root");
         Tree month = matcher.GetNode("month");
         Tree day = matcher.GetNode("day");
         Tree comma = matcher.GetNode("comma");
         Tree year = matcher.GetNode("year");
         var children = new Tree[] {month, day, comma, year};
         root.SetChildren(children);
         matcher = TregexMonthDayYear.Matcher(t);
     }
     return t;
 }
开发者ID:gblosser,项目名称:OpenNlp,代码行数:26,代码来源:DateTreeTransformer.cs

示例8: ComputeId

        public static string ComputeId(Tree tree)
        {
            using (var md = new MessageDigest())
            {
                using (var ms = new MemoryStream())
                {
                    foreach (var item in tree.Items)
                    {
                        var data = Encoding.Default.GetBytes(string.Format("{0} {1}\0", item.Mode, item.Name));
                        ms.Write(data, 0, data.Length);

                        var id = Helper.IdToByteArray(item.Id);
                        ms.Write(id, 0, id.Length);
                    }

                    var header = Encoding.Default.GetBytes(string.Format("tree {0}\0", ms.Length));
                    ms.Position = 0;
                    md.Update(header);
                    md.Update(ms);
                }
                var digest = md.Digest();

                return Helper.ByteArrayToId(digest);
            }
        }
开发者ID:kthompson,项目名称:gitty,代码行数:25,代码来源:ObjectWriter.cs

示例9: Main

        static void Main()
        {
            Tree<int> tree =
            new Tree<int>(3,
                          new Tree<int>(5,
                                        new Tree<int>(0),
                                        new Tree<int>(1),
                                        new Tree<int>(6)),
                          new Tree<int>(2,
                                        new Tree<int>(4)));

            Console.WriteLine("Depth-First Search (DFS) traversal (recursive):");
            tree.TraverseDFS();
            Console.WriteLine();

            Console.WriteLine("Breadth-First Search (BFS) traversal (with queue):");
            tree.TraverseBFS();
            Console.WriteLine();

            Console.WriteLine();
            Console.WriteLine("Depth-First Search (DFS) traversal (with stack):");
            tree.TraverseDFSWithStack();
            Console.WriteLine();

            Console.WriteLine("Root: {0}", tree.Root.Value);

            Console.Write("Leafs: ");
            tree.TraverseLeafs(tree.Root);
            Console.WriteLine();
        }
开发者ID:georgimanov,项目名称:Data-Structures-and-Algorithms,代码行数:30,代码来源:Startup.cs

示例10: DisplayTree

        private static void DisplayTree(Tree<int> tree)
        {
            var serializer = new XmlSerializer(tree.GetType());
            serializer.Serialize(Console.Out, tree);

            Console.WriteLine();
        }
开发者ID:Maceage,项目名称:DesignPatterns,代码行数:7,代码来源:TreeExamples.cs

示例11: NonFullRootNodeTest

		public void NonFullRootNodeTest ()
		{
			var tree = new Tree<int, string>(new TreeMemoryNodeManager<int, string>(2, Comparer<int>.Default),
				allowDuplicateKeys: true);

			tree.Insert (1, "1");

			Assert.AreEqual (0, (from node in tree.LargerThan(7) select node).Count());
			Assert.AreEqual (0, (from node in tree.LargerThanOrEqualTo(7) select node).Count());
			Assert.AreEqual (1, (from node in tree.LessThan(7) select node).FirstOrDefault().Item1);
			Assert.AreEqual (1, (from node in tree.LessThanOrEqualTo(7) select node).FirstOrDefault().Item1);
			Assert.AreEqual (1, (from node in tree.LessThanOrEqualTo(1) select node).FirstOrDefault().Item1);
			Assert.AreEqual (0, (from node in tree.LessThan(1) select node).Count());

			tree.Insert (5, "5");
			tree.Insert (9, "9");

			// 1,5,9

			Assert.IsTrue ((from node in tree.LessThanOrEqualTo(9) select node.Item1).SequenceEqual(new int[] { 9, 5, 1 }));
			Assert.IsTrue ((from node in tree.LessThan(9) select node.Item1).SequenceEqual(new int[] { 5, 1 }));
			Assert.IsTrue ((from node in tree.LargerThanOrEqualTo(5) select node.Item1).SequenceEqual(new int[] { 5, 9 }));
			Assert.IsTrue ((from node in tree.LargerThan(5) select node.Item1).SequenceEqual(new int[] { 9 }));


			Assert.DoesNotThrow(delegate {
				tree.Insert (5, "5.1");
			});

			// Iterating test
			var found = (from node in tree.LargerThanOrEqualTo(5) select node.Item2).ToList ();
			Assert.AreEqual (3, found.Count);
			Assert.IsTrue (found.Contains("5.1"));
			Assert.IsTrue (found.Contains("5"));
		}
开发者ID:K-Eo,项目名称:FooDB,代码行数:35,代码来源:BTreeNonUniqueTest.cs

示例12: DoTable

 public static void DoTable(Tree<Cell> table, Interpreter activeFixture, bool inFlow)
 {
     var activeFlowFixture = activeFixture as FlowInterpreter;
     if (activeFlowFixture != null) activeFlowFixture.DoSetUp(table);
     activeFixture.Interpret(table);
     if (activeFlowFixture != null && !inFlow) activeFlowFixture.DoTearDown(table);
 }
开发者ID:narkedboy,项目名称:fitsharp,代码行数:7,代码来源:ExecuteStoryTest.cs

示例13: PopulateTree

		public override void PopulateTree (Tree tree)
		{
			var doc = XDocument.Load (tocFile);
			var uls = doc.Descendants (ns + "body").First ().Elements (ns + "ul");
			foreach (var ul in uls)
				ParseUl (tree, tree.RootNode, ul);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:xhtml-provider.cs

示例14: Interpret

 public void Interpret(CellProcessor processor, Tree<Cell> table)
 {
     new Traverse<Cell>()
         .Rows.Header(row => headerRow = row)
         .Rows.Rest(row => ComputeRow(processor, row))
         .VisitTable(table);
 }
开发者ID:JeffryGonzalez,项目名称:fitsharp,代码行数:7,代码来源:Compute.cs

示例15: BuildTree_PrintTree_ShouldWorkCorrectly

    public void BuildTree_PrintTree_ShouldWorkCorrectly()
    {
        // Arrange
        var tree =
            new Tree<int>(7,
                new Tree<int>(19,
                    new Tree<int>(1),
                    new Tree<int>(12),
                    new Tree<int>(31)),
                new Tree<int>(21),
                new Tree<int>(14,
                    new Tree<int>(23),
                    new Tree<int>(6)));

        // Act
        var outputStream = new MemoryStream();
        using (var outputWriter = new StreamWriter(outputStream))
        {
            Console.SetOut(outputWriter);
            tree.Print();
        }
        var output = Encoding.UTF8.GetString(outputStream.ToArray());

        // Assert
        var expectedOutput = "7\n  19\n    1\n    12\n    31\n  21\n  14\n    23\n    6\n";
        output = output.Replace("\r\n", "\n");
        Assert.AreEqual(expectedOutput, output);
    }
开发者ID:stansem,项目名称:SoftUni,代码行数:28,代码来源:Test.cs


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