Reputation: 1732
Does anyone know of a sorted collection class in Silverlight 4? SortedSet<T>, SortedList<T>, and SortedDictionary<T> all seem to be missing.
Of course I can use List<T>.Sort(), or the IEnumerable<T>.OrderBy() extension method. But I'd rather not have to do an O(n log n) sort every time an element is added or removed.
Thanks for your help,
Richard
Upvotes: 3
Views: 3450
Reputation: 1030
I was looking for something similar to SortedList in .NET (Something that stays sorted, not using LINQ over a dictionary or a collection to do sorting). I wasn't able to find anything so I came up with this solution. It works similar to a dictionary, maintaining a collection of keys and values and keeping both collections sorted by the key.
Upvotes: 0
Reputation: 2241
Unfortunately sorted collections haven't made it into Silverlight (yet?)
You could have a look at The C5 Generic Collection Library, there's quite a lot of useful things in there, but possibly a bit heavyweight to import into your app depending how much you need.
The Silverlight Toolkit also includes an ordered dictionary based on Red-Black trees.
Upvotes: 2
Reputation: 69262
Here you go. You can find a lot of Mono source code for missing framework classes just by searching for the name of the class + ".cs" on Google.
http://www.koders.com/csharp/fid77AAA5D3D43E8EA58F8D9EFE52B8798463A68472.aspx
Sometimes you have to work out some compiler errors first but it should get you on your way.
Upvotes: 5