为什么没有树< T> .NET中的类? [英] Why is there no Tree<T> class in .NET?

查看:99
本文介绍了为什么没有树< T> .NET中的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET中的基类库对于集合(List,Queue,Stack,Dictionary)有一些很好的数据结构,但奇怪的是它不包含二进制树的任何数据结构。对于某些算法,如利用不同遍历路径的算法,这是非常有用的结构。我正在寻找一个正确的书面,免费的实施。

The base class library in .NET has some excellent data structures for collections (List, Queue, Stack, Dictionary), but oddly enough it does not contain any data structures for binary trees. This is a terribly useful structure for certain algorithms, such as those that take advantage of different traversal paths. I'm looking for a correctly written, free implementation.

我只是盲目,而不是找到它...是埋在BCL的某个地方吗?如果没有,有人可以为二叉树推荐一个免费或开源的C#/ .NET库吗?最好是使用泛型。

Am I simply blind, and not finding it... is it buried somewhere in the BCL? If not, can someone recommend a free or open-source C#/.NET library for binary trees? Preferably one that employs generics.

编辑:澄清我正在寻找什么。我对在内部使用树的有序字典集合感兴趣。我实际上对一个二叉树感兴趣,一个公开其结构,以便您可以执行诸如提取子树之类的操作,或在节点上执行修复后遍历。理想情况下,这样一个类可以被扩展,以提供专门树(即红/黑,AVL,平衡等)的行为。

To clarify what I'm looking for. I'm not interested in ordered dictionary collections that internally use a tree. I'm actually interested in a binary tree - one that exposes its structure so that you can do things like extract subtrees, or perform post-fix traversal on the nodes. Ideally such a class could be extended to provide the behaviors of specialized trees (ie. Red/Black, AVL, Balanced, etc).

推荐答案

你是对的,BCL没有什么。我怀疑这是因为是否使用树的选择通常是实现细节,否则是访问数据的非常规方式。也就是说,你不要说二元搜索元素#37;相反,你说,得到我的元素#37。

You're right, there's nothing in the BCL. I suspect this is because the choice of whether to use a tree is typically an implementation detail and is otherwise an unconventional way to access data. That is, you don't say, "binary-search-for element #37"; instead, you say, "get me element #37".

但是你看了一下 C5 ?它是超级方便的,它们有几个树实现( 1 2 3 )。

But have you taken a look at C5? It's super-handy and they have several tree implementations (1, 2, 3).

这篇关于为什么没有树< T> .NET中的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆