Reputation: 25938
If I give my SortedList
a custom IComparer
does that affect the lists Lookup
and Insertion
efficiency and algorithm?
I know that by default the SortedList
uses a Binary Search for lookup and insertion. By making my own custom comparer will Lookup
and Insertion
still be done by Binary Search? Will a custom comparer affect efficiency now?
SortedList <double, GO> list = new SortedList(new MyComparer());
public class MyComparer : IComparer
{
public void Compare(double a, double b) {
...
}
}
Upvotes: 2
Views: 199
Reputation: 144196
By default, SortedList<K, V>
uses the IComparer<K>.Default
for comparing keys if you don't provide the comparer in the constructor. There is no functional difference beyond that.
Upvotes: 2