Question

I am looking for a memory and performance efficient implementation of SortedSet<T> (corresponding to System.Collections.Generic.SortedSet<T> in vanilla .NET).

For the time being, I have taken a very simplistic approach, implementing the ISet<T> interface and internally storing the items in a List<T> that I re-sort after every data inclusion:

public class SortedSet<T> : ISet<T>
{
    private List<T> _collection; 
    private readonly IComparer<T> _comparer;
    ...
}

I have taken a look at the Mono source code for SortedSet, but as far as I can tell this implementation is not easily portable to Silverlight. There is also the SortedArray class in the C5 generic collection class library that I believe is applicable to Silverlight, but then I would probably need to include the entire C5 library. I would prefer a more light-weight solution.

Does anyone have any recommendations of a light-weight, fast and memory efficient open-source SortedSet<T> implementation applicable to Silverlight?

Was it helpful?

Solution

You could implement your SortedSet<T> to internally use the Mono implementation of SortedList<TKey, TValue>. At first glance, this has not so much dependencies to other Mono code as SortedSet<T>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top