19

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.

Breeze
  • 2,010
  • 2
  • 32
  • 43
usr021986
  • 3,421
  • 14
  • 53
  • 64

2 Answers2

9

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.

Emily
  • 1,030
  • 1
  • 12
  • 20
user7610
  • 25,267
  • 15
  • 124
  • 150
3

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/

Loga
  • 658
  • 1
  • 7
  • 17