[英]Is there an equivalent of std::set in C#?
I would like to have a container 我想要一个容器
StdStyleSet<A>
of 的
class A : IComparable<A> { ... }
which satisfies the properties of std::set. 它满足std :: set的属性。 This would especially be: 这尤其是:
SortedSet<T>
: see documents - although technically, it's in the .NET Framework. SortedSet<T>
:请参阅文档 - 虽然从技术上讲,它位于.NET Framework中。
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. 对于早期版本,您可以使用HashSet并使用LINQ进行排序,如果您主要以有序方式使用集合,则不理想。 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. 或者,您可以使用SortedDictionary<TKey,TValue>
,其值为Object
,并将元素存储在值为null的键中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.