Java 中的 TreeSet 等效于 C#.net

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6827913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:26:57  来源:igfitidea点击:

Equivalent of TreeSet in Java to C#.net

c#javacollectionsgenerics

提问by usr021986

I have Java code containing a TreeSet. I want to convert the code to C#.

我有包含TreeSet. 我想将代码转换为 C#。

Which equivalent collection can I use?
If there is none please suggest alternatives.

我可以使用哪个等效集合?
如果没有,请提出替代方案。

采纳答案by Loga

I think there is no treeset in C#.

我认为 C# 中没有树集。

There was similar question asked in msdn, check that may be useful. http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/823c46ca-4a60-4429-a606-e76c3195d4cc/

在 msdn 中提出了类似的问题,检查可能有用。 http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/823c46ca-4a60-4429-a606-e76c3195d4cc/

回答by user7610

That would be System.Collections.Generic.SortedSet<T>.

那将是System.Collections.Generic。SortedSet<T>.

It does have the methods and complexity guarantees that one would expect from a balanced tree-backed data structure. You can find maximum, minimum, iterate through all elements in order, everything.

它确实具有人们期望从平衡的树支持数据结构中获得的方法和复杂性保证。你可以找到最大值,最小值,按顺序遍历所有元素,一切。

See Add to SortedSet<T> and its complexityfor more on that.

有关更多信息,请参阅添加到 SortedSet<T> 及其复杂性