473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SorteList Comparer: how to change it on the fly?

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

Jul 18 '06 #1
2 1218
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

<to**************@uniroma1.itwrote in message
news:11*********************@75g2000cwc.googlegrou ps.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

Jul 18 '06 #2
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:
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

<to**************@uniroma1.itwrote in message
news:11*********************@75g2000cwc.googlegrou ps.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
Jul 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric Newton | last post by:
come on framework guys ;-) probably an oversight but lets fix it and get a simple default comparer into v1.2? ...
1
by: sho_nuff | last post by:
Hello all, I have a sorted list that contains items: foo1 foo2 foo3 foo10 foo11 foo12
0
by: Frank Wisniewski | last post by:
Hi All, I have created my own generic comparer object which implements IComparer and uses reflection. I have tested it and it seem to work fine but I am worried about the way I did it. My goal...
3
by: MattC | last post by:
Hi, I found this code somewhere on the net and need to make some alterations. public class GenericSorter : IComparer { String sortProperty; bool sortOrder; public GenericSorter(String...
2
by: cindy | last post by:
i build a string string eProduct = "#blah#ablah#bbbb"; StringBuilder sb = new StringBuilder(eProduct); eProduct = sb.Replace("#","").ToString(); string aProducts= eProduct.Split(';'); then I...
2
by: Luc The Perverse | last post by:
Hello! I am trying to find a way to deal with Windows' case insensitivity without just forcing everything lowercase. While I am open to criticism on my method - my question relates to the...
3
by: radom | last post by:
How do i use the Comparer fuction thanks radom
6
by: Tony | last post by:
Hello! My first question: I just can't figure out what is the usefulness of Comparer.Default.Compare(somestring1, somestring2); because I can just the same use...
10
by: Tony | last post by:
Hello! I'm reading in a book and this can't be correct it says. "Objects passed to Comparer.Compare() are checked to see if they support IComparable. If they do, then that implementation is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.