tags:

views:

173

answers:

3

Dear all

It looks SortedList is excluded.. What do you think most appropriate out of existing collections? (to keep the same fast access and changes)

Can silverlight Dictionary be permanently sorted?

Best regards VLK

A: 

To answer your question: No. The dictionary does not guarantee ordered items by key.

However the List<T> supports the BinarySearch method. This can help you acheive similar goals of the SortedList.

The documentation has a nice example of how that is basically acheived. See:-

List<T>.BinarySearch Method (T)

AnthonyWJones
thank you, still the doc says:The List<T> must already be sorted according to the comparer implementation; otherwise, the result is incorrect.
VLK
ah, your idea is to keep list always sorted inserting in position given by BinarySearch..hm, I'll check a dependency of insertion time to collection size.
VLK
A: 

You might take a look at Wintellect's Power Collections. This library is free under the EPL. I think the OrderedMultiDictionary will do the trick for you. You should be able to compile this under Silverlight. I have not used this for a couple of years but did use this library (and Richter's threading library) for a WPF project.

Edit:

After playing around with this it looks like you will need to do a little work to get the power collections to work in Silverlight.

Jason Jackson
A: 

I ported both the Wintellect Power Collections and the C5 Generic Collections to Silverlight. I made them available here - http://jaykimble.net/powercollections-and-c5-collections-for-silverlight4.aspx.

I did this mostly because this question peaked my interest. Feel free to use them in any type of project you would like to use them with.

DevTheo