Duplicates in a Sorted List

  • Thread starter Thread starter Tom Scales
  • Start date Start date
T

Tom Scales

I've got a new problem (making progress on my GetFiles problem).

I have a need to keep a large number of entries in a SortedList. My
challenge is that there are duplicate entries in the key. That's OK for my
application, but not for a Sorted list.

Any thoughts?

Thanks,

Tom
 
You are right. SortedList does not support duplicated keys. Since I don't
know what is the exactly problem you want to resolve, I can't say what is
better data structure you can use. You can always write your own
collection to fit your application, but if you don't want to do this, one
simple solution is to put a collection (like an arrany list) into the
sortedList when you get duplicated values for a single key, and insert your
real values into that collection. You can decide whether all values in the
sortedList are collections, or only the dup items are collections, and you
do the check all the time. The first one is easy to implement, but costs
more memory. Of course, there will be some performance hit.

Thanks
Lifeng
MS VB team
 
I had a group of items to sort with duplicates. The sort was numbers so
this worked:

i = 0
for i = 0 to source.count - 1
key = source.key *100 + i
sorted.add(key,source.data)
next
 
Back
Top