问题
I have Java code containing a TreeSet
. I want to convert the code to C#.
Which equivalent collection can I use?
If there is none please suggest alternatives.
回答1:
I think there is no treeset in 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/
回答2:
That would be 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 complexity for more on that.
来源:https://stackoverflow.com/questions/6827913/equivalent-of-treeset-in-java-to-c-net