![](/img/trans.png)
[英]What is wrong with my IEquatable<T>, IComparable<T> implementation? SortedList throws ArgumentException
[英]SortedList that just takes IComparable<T>
我有一个接口IScriptItem
,它实现了IComparable<IQueueItem>
。 在我看来,似乎有足够的IComparable
项目来排序任何东西。 但我能找到的只是Dictionaries,Hashtables和SortedLists,它们实际上是SortedTrees。
我正在寻找的是一个排序的通用列表,它采用IComparables。 我在错误的地方看?
内置任何东西都没有。 你有一些选择:
对于这个特殊情况,请查看Wintellect PowerCollections OrderedBag类,它在内部使用红黑树。 其他好的免费数据结构库包括NGenerics和C5。
如果我理解正确,你需要一个SortedCollection <TValue>而不是那里的各种SortedCollection <TKey,TValue>。
在.NET 4中,有一个新的SortedSet<T>
类,它保持其项目的顺序,但不允许重复。 否则你将不得不看第三方选项,如Matt Howells提到的选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.