Home All Groups Group Topic Archive Search About

SorteList Comparer: how to change it on the fly?

Author
18 Jul 2006 12:46 PM
tommaso.gastaldi
Hi, I need to change at runtime the Comparer of a SortedList of mine
(it does not seem to expose a Comparer or Icomparer property).

Do you know how can I do that (clearly without reconstructing the SL) ?

Thanks

-Tom

Author
18 Jul 2006 1:44 PM
Claes Bergefall
Only way I can see is by either creating a new one (using the contstructor
that takes an IDictionary and an IComparer) or somehow change the
IComparable implementation of the keys

   /claes

<tommaso.gasta***@uniroma1.it> wrote in message
Show quoteHide quote
news:1153226801.907768.74660@75g2000cwc.googlegroups.com...
> Hi, I need to change at runtime the Comparer of a SortedList of mine
> (it does not seem to expose a Comparer or Icomparer property).
>
> Do you know how can I do that (clearly without reconstructing the SL) ?
>
> Thanks
>
> -Tom
>
Author
18 Jul 2006 2:20 PM
tommaso.gastaldi
Thank you Claes, I will go the second way you suggest.

Once I change the implementation, I may need to force
a reordering of the existing list, for compare purpose - before
adding or removing any item  (which would force the reorder) -
Can you see a meaningful way to force the reordering ?

-Tommaso

Claes Bergefall ha scritto:

Show quoteHide quote
> Only way I can see is by either creating a new one (using the contstructor
> that takes an IDictionary and an IComparer) or somehow change the
> IComparable implementation of the keys
>
>    /claes
>
> <tommaso.gasta***@uniroma1.it> wrote in message
> news:1153226801.907768.74660@75g2000cwc.googlegroups.com...
> > Hi, I need to change at runtime the Comparer of a SortedList of mine
> > (it does not seem to expose a Comparer or Icomparer property).
> >
> > Do you know how can I do that (clearly without reconstructing the SL) ?
> >
> > Thanks
> >
> > -Tom
> >