1
Answer

HowTO sort objects without IComparible?

thomas.menzel2

thomas.menzel2

21y
2.1k
1
Hi, i need to store several obects in a set (ie. only one entry per object). the objects are very different and not all implement the IComparable interface. since the set may get VERY large and finding is time-critical, it is not feasable to check allways against all entries in the set with Object.ReferenceEquals(); - hence the idea to sort them. In C/C++ one could just compare the pointer-values (ie. addresses) as that is very fast (int comparison) and ensures uniqueness, for all objects alive. However, the addresses of managed objects are not obtainable. anybody that can help me? my current workaround is to use a Hashtable but since they use linked lists, performance can be still bad if I'm unlucky. thanx
Answers (1)