排序列表,仅仅需要IComparable的< T> [英] SortedList that just takes IComparable<T>

查看:149
本文介绍了排序列表,仅仅需要IComparable的< T>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个接口 IScriptItem 实现 IComparable的< IQueueItem> 。 在我眼里这似乎足有才能有一个排序的任何 IComparable的项目。但是,所有我能找到的是字典,哈希表和SortedLists,实际上是SortedTrees。

I have an interface IScriptItem that implements IComparable<IQueueItem>. In my eyes it would seem enough to have IComparable items in order to have a sorted anything. But all I can find is Dictionaries, Hashtables and SortedLists that are actually SortedTrees.

我正在寻找的是一个通用的排序列表中需要IComparables。 我是不是找错了地方?

What I'm looking for is a sorted generic list that takes IComparables. Am I looking in the wrong places?

推荐答案

没有什么内置。你有一些选择:

There's nothing built-in. You have some options:

  • 使用排序列表与虚拟TValue。
  • 使用列表或数组,并调用List.Sort()或的Array.Sort()在必要的时候。
  • 在写自己的。
  • 使用第三方库

对于这种特殊情况下,检查了Wintellect的PowerCollections OrderedBag类,它采用了红黑树内部。其他良好的免费数据结构库包括NGenerics和C5。

For this particular case check out Wintellect PowerCollections OrderedBag class, which uses a red-black tree internally. Other good free data structure libraries include NGenerics and C5.

这篇关于排序列表,仅仅需要IComparable的&LT; T&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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