即重新present树对象对象、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?我说的不是prese...

有没有在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; }

  // ...
}
阅读全文

相关推荐

最新文章