S
saurabh
I have a list of mytype objects which need to be stored as a sorted
collection. The mytype implements IComparable. For some reason someone else
has implemented it as a normal collection. but whenever an element is added,
it calculates the insertion point and then does Array.Copy to move all the
elemnts from the insertion point to the end and then insert the new mytype
object at the insertion point, similar things for removing the element.
As mytype already implements IComparable. I have been thinking of replacing
the current collection with a SortedList and add the same object as a Key as
well as Value. This will mean that the Keys collection of sorted list will
be equivalent to the existing collection which I've got.
My question is A) Is my thinking correct or am I missing something very
obvious and B) Will I be able to gain a speed improvement by doing this?
TIA
Saurabh
collection. The mytype implements IComparable. For some reason someone else
has implemented it as a normal collection. but whenever an element is added,
it calculates the insertion point and then does Array.Copy to move all the
elemnts from the insertion point to the end and then insert the new mytype
object at the insertion point, similar things for removing the element.
As mytype already implements IComparable. I have been thinking of replacing
the current collection with a SortedList and add the same object as a Key as
well as Value. This will mean that the Keys collection of sorted list will
be equivalent to the existing collection which I've got.
My question is A) Is my thinking correct or am I missing something very
obvious and B) Will I be able to gain a speed improvement by doing this?
TIA
Saurabh