[.net] Container equivalent to C++ set?

Started by
3 comments, last by osmanb 17 years, 11 months ago
I've only been working with C#/.NET for a short time, but I generally find it really easy to use. Every time I've wanted to do something, it took one Google search to turn up something in the standard library. Today, though, I wanted a container that worked like the STL set from C++. For all of the web-pages that brag about how much better the .NET containers are than the STL ones, and how you should never need to write your own, I can't find anything that works like set. I want a collection of values that remains sorted. There doesn't seem to be anything... All of the sorted containers use both keys and values. It seems like I either have to write my own, or do something nasty like: SortedList< MyType, int > At which point I'll simply ignore the value portion and end up using .Keys to do most of my work. Have I overlooked something? Or is there a better solution than my (ab)use of SortedList?
Advertisement
Look at System.Collections, they may have what you are looking for.

theTroll
I'd be interested in this too. It seems a strange omission.
There's nothing quite like it. It should be fairly easy to grab some code for an AVL or RB tree from the net and create an ISet interface for it tough.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
Thanks for the replies. I just wanted to be sure I hadn't overlooked anything. I checked every container in Collections and the sub-namespaces, but no luck. Anyways, I've simply used one of the dictionary style (Key/Value) containers for now, wrapped in a one-off container that support indexing and enumeration. I might go back later and implement a proper generic Set, but my application is simple enough that this works.

This topic is closed to new replies.

Advertisement