.NET 4 中有二叉搜索树实现吗?

发布于 2024-09-26 23:36:26 字数 35 浏览 0 评论 0原文

我正在寻找 .NET 4 中的内置二叉搜索树实现。有吗?

I'm looking for a built-in Binary Search Tree implementation in .NET 4. Is there one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

尸血腥色 2024-10-03 23:36:26

SortedDictionary 类使用 Tree,这就是您想要的吗?

请参阅此SO答案进行讨论。

The SortedDictionary<K,V> class uses a Tree, is that what you're after?

See this SO answer for a discussion.

如若梦似彩虹 2024-10-03 23:36:26

另一种选择是使用列表并对其进行排序。然后您可以使用 BinarySearch 方法来查找项目。要维护排序列表,您可以使用 BinarySearch 返回的索引进行插入。如果返回的索引为负,请使用补码(〜运算符)作为插入位置,如果返回的索引为正,则可以在该位置插入(除非您想要设置类似的行为,在这种情况下根本不插入)。

Another option is to use a List and sort it. Then you can use the BinarySearch method to find items. To maintain the sorted list you can use the index returned by the BinarySearch to insert at. If the returned index is negative use the complement (~ operator) as your insert location, if the returned index is positive you can insert at that location (unless you want set like behavior in which case don't insert at all).

開玄 2024-10-03 23:36:26

C5 库

类 TreeDictionary 实现接口 ISortedDictionary 并表示
使用有序平衡红黑的(键,值)对或条目的字典
二叉树。条目访问、条目删除和条目插入需要时间O(logn)。
树字典的键、值或条目的枚举遵循键顺序,
由关键比较器确定。

C5 library:

Class TreeDictionary implements interface ISortedDictionary and represents
a dictionary of (key,value) pairs, or entries, using an ordered balanced redblack
binary tree. Entry access, entry deletion, and entry insertion take time O(logn).
Enumeration of the keys, values or entries of a tree dictionary follow the key order,
as determined by the key comparer.

醉殇 2024-10-03 23:36:26

http://code.google.com/p/self-balancing-avl-树/。平衡 AVL 树实现,具有连接和拆分操作以及基于 AVL 树的 SortedDictinary 和 SortedMultiDictionary。

http://code.google.com/p/self-balancing-avl-tree/. Balanced AVL tree implementation with concatenate and split operations as well as SortedDictinary and SortedMultiDictionary based on the AVL tree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文