即重新present树对象 [英] Objects that represent trees
本文介绍了即重新present树对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有在C#中的任何对象(或.NET)的重新presents二叉树(或好奇)和正叉树?
Are there any objects in C# (or in .net) that represents a binary tree (or for curiosity) and n-ary tree?
我说的不是presentation树形控件,但作为模型对象。
I am not talking about presentation tree controls, but as model objects.
如果不是,请问有什么好的外部实现?
If not, are there any good external implementations?
推荐答案
在 NGenerics 项目是数据结构和算法的真棒集合包括二叉树。
The NGenerics project is a awesome collection of data structures and algorithms including a Binary Tree.
public class BinaryTree<T> : IVisitableCollection<T>, ITree<T>
{
// Methods
public void Add(BinaryTree<T> subtree);
public virtual void breadthFirstTraversal(IVisitor<T> visitor);
public virtual void
DepthFirstTraversal(OrderedVisitor<T> orderedVisitor);
public BinaryTree<T> GetChild(int index);
public bool Remove(BinaryTree<T> child);
public virtual void RemoveLeft();
public virtual void RemoveRight();
// ...
// Properties
public virtual T Data { get; set; }
public int Degree { get; }
public virtual int Height { get; }
public virtual bool IsLeafNode { get; }
public BinaryTree<T> this[int i] { get; }
public virtual BinaryTree<T> Left { get; set; }
public virtual BinaryTree<T> Right { get; set; }
// ...
}
这篇关于即重新present树对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文