是否有一个std ::相当于在C#中设置? [英] Is there an equivalent of std::set in C#?
本文介绍了是否有一个std ::相当于在C#中设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想有一个容器
StdStyleSet<A>
的
class A : IComparable<A> { ... }
满足性病的属性设置::。这尤其是:
which satisfies the properties of std::set. This would especially be:
- 自己的人是
- 自动排序上插入密钥的元素LI>
推荐答案
的SortedSet< T>
:见文件的 - 虽然在技术上,它在.NET框架
SortedSet<T>
: see documents - although technically, it's in the .NET Framework.
有关早期版本中,你可以使用一个HashSet的和排序使用LINQ,而不是理想的,如果你主要是在消耗一个有序的方式设置。另外,您可以使用 SortedDictionary< TKEY的,TValue>
的值对象
和存储您的内容与键为空值的值。
For earlier versions, you could use a HashSet and sort using LINQ, not ideal if you're primarily consuming the set in an ordered fashion. Alternatively you could use a SortedDictionary<TKey,TValue>
with the value as Object
and store your elements in the keys with nulls for the values.
这篇关于是否有一个std ::相当于在C#中设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文