本文整理汇总了C#中Tree类的典型用法代码示例。如果您正苦于以下问题:C# Tree类的具体用法?C# Tree怎么用?C# Tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于命名空间,在下文中一共展示了Tree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Iterate
private static Map Iterate(ConcurrentQueue<Tuple<Map, char>> queue, Tree tree)
{
Tuple<Map, char> var;
while (!queue.TryDequeue(out var)) System.Threading.Thread.Sleep(5);
var currentMap = var.Item1;
var cars = currentMap.Parse();
//Console.WriteLine("Checking:\n" + currentMap);
if (cars.ContainsKey(Globals.TargetCar) && cars[Globals.TargetCar].Item1.Equals(targetLocation))
return currentMap;
foreach (var kvp in cars)
if (kvp.Key != var.Item2) {
Map move;
bool horizontal = kvp.Value.Item3 == Direction.Right;
for (int i = 1; i <= (horizontal ? kvp.Value.Item1.X : kvp.Value.Item1.Y); i++) {
move = currentMap.makeMove(kvp.Key, kvp.Value.Item1, kvp.Value.Item3.Invert(), kvp.Value.Item2, i);
if (move != null) {
NewMethod(queue, tree, currentMap, kvp, move);
}
else break;
}
for (int i = 1; i < (horizontal ? map.map.GetLength(0) - kvp.Value.Item1.X : map.map.GetLength(1) - kvp.Value.Item1.Y); i++) {
move = currentMap.makeMove(kvp.Key, kvp.Value.Item1, kvp.Value.Item3, kvp.Value.Item2, i);
if (move != null) {
NewMethod(queue, tree, currentMap, kvp, move);
}
else break;
}
}
if (queue.Count == 0) return Globals.NoSolutions; // We don't have anything to add
return null; // no solution found yet
}
开发者ID:kutagh,项目名称:RushHour,代码行数:31,代码来源:Program.cs
示例17: SaveTree
public static void SaveTree(String TreeXml)
{
if (String.IsNullOrEmpty(TreeXml))
{
//创建一棵空树
XElement root = new XElement("root");
TreeXml = root.ToString();
}
using (InfocenterEntities context = new InfocenterEntities(DALConfig.ConnectString))
{
Tree treeObj = context.Trees.FirstOrDefault();
if (treeObj != null)
{
//更新树
treeObj.maintree = Encoding.UTF8.GetBytes(TreeXml);
context.SaveChanges();
}
else
{
//正常情况下应该不会走到这个分支,但仍然写在这里,逻辑就完整了。
treeObj = new Tree();
treeObj.maintree = Encoding.UTF8.GetBytes(TreeXml);
context.Trees.Add(treeObj);
context.SaveChanges();
}
}
}
开发者ID:puma007,项目名称:PersonalInfoForWPF,代码行数:29,代码来源:MainTreeRepository.cs
示例18: Main
static void Main()
{
Node<int> root = new Node<int>(5);
Tree<int> tree = new Tree<int>(root);
tree.Add(new Node<int>(7));
tree.Add(new Node<int>(1));
tree.Add(new Node<int>(2));
tree.Add(new Node<int>(9));
tree.Add(new Node<int>(4));
tree.Add(new Node<int>(8));
tree.Add(new Node<int>(0));
tree.Add(new Node<int>(11));
tree.Add(new Node<int>(-3));
tree.Add(new Node<int>(-6));
tree.Add(new Node<int>(-5));
tree.Add(new Node<int>(-8));
tree.Add(new Node<int>(5));
tree.Add(new Node<int>(12));
tree.Print();
tree.FindLongestPath();
Console.WriteLine("++++++++++++++++++++++++++++");
var allSubTreessWithSum = tree.FindSubtreesWithSum(-10);
foreach (var subTree in allSubTreessWithSum)
{
subTree.Print();
}
}
开发者ID:huuuskyyy,项目名称:CSharp-Homeworks,代码行数:32,代码来源:Program.cs
示例19: SetLastIndex
public void SetLastIndex(Tree t)
{
lastIndex = 0;
var iterator = t.Iterator();
while (iterator.MoveNext())
{
var node = iterator.Current;
/*foreach (Tree node in t) {*/
string value = node.Label().Value();
if (value != null)
{
var m = coindexationPattern.Match(value);
if (m.Success)
{
int thisIndex = 0;
try
{
thisIndex = int.Parse(m.Groups[1].Value);
}
catch (FormatException e)
{
// Ignore this exception. This kind of exception can
// happen if there are nodes that happen to have the
// indexing character attached, even despite the attempt
// to ignore those nodes in the pattern above.
}
lastIndex = Math.Max(thisIndex, lastIndex);
}
}
}
}
开发者ID:gblosser,项目名称:OpenNlp,代码行数:31,代码来源:CoindexationGenerator.cs
示例20: bindPages
private void bindPages( List<Page> list )
{
Tree<Page> tree = new Tree<Page>( list );
IBlock block = getBlock( "list" );
foreach (Page data in tree.GetAllOrdered()) {
block.Set( "data.Id", data.Id );
block.Set( "data.OrderId", data.OrderId );
block.Set( "data.AddSubLink", to( AddSubPage, data.Id ) );
int indentLength = tree.GetDepth( data.Id ) * 20;
String indent = "padding-left:" + indentLength + "px";
block.Set( "data.Indent", indent );
block.Set( "data.Title", data.Title );
block.Set( "data.Created", data.Created );
block.Set( "data.Hits", data.Hits );
block.Set( "data.ReplyCount", data.Replies );
block.Set( "data.IsAllowReplyStr", data.IsAllowReplyStr );
block.Set( "data.ViewUrl", to( ViewUrl, data.Id ) );
block.Set( "data.LinkShow", plink( data.Id ) );
block.Set( "data.LinkDelete", to( Delete, data.Id ) );
block.Set( "data.LinkEdit", to( Edit, data.Id ) );
block.Next();
}
}
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:32,代码来源:PageController.cs
注:本文中的Tree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论