有没有在.NET中的有序集合类型? [英] Is there a sorted collection type in .NET?

查看:218
本文介绍了有没有在.NET中的有序集合类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个容器,一直在为了它的所有项目。我看着SortedList的,但是这需要一个单独的密钥,并且不允许重复键。我也可以只使用一个无序的容器,并明确每个插入后排序。

I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert.

用法:

  • 偶尔插入
  • 为了
  • 频繁遍历
  • 在理想的情况下不与键从工作实际对象分开,使用比较函数进行排序。
  • 为等效对象
  • 稳定的排序是需要的,但不是必需的。
  • 随机存取不是必需的。
  • Occasional insert
  • Frequent traversal in order
  • Ideally not working with keys separate from the actual object, using a compare function to sort.
  • Stable sorting for equivalent objects is desired, but not required.
  • Random access is not required.

我知道我可以自己建一个平衡的树结构,我只是想知道,如果框架已经包含了这样的野兽。

I realize I can just build myself a balanced tree structure, I was just wondering if the framework already contains such a beast.

推荐答案

您可能想看看在 Wintellect的力量集合。它可在codePLEX并含有相当多的收藏品,是非常有帮助的。该OrderedBag集合中的项目正是你所期待的。它主要是靠红黑树提供了pretty的有效排序。

You might want to take a look at the Wintellect Power Collections. It is available on CodePlex and contains quite a few collections that are very helpful. The OrderedBag collection in the project is exactly what you are looking for. It essentially uses a red-black tree to provide a pretty efficient sort.

这篇关于有没有在.NET中的有序集合类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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