1
Reply

HowTO sort objects without IComparible?

thomas.menzel2

thomas.menzel2

Nov 5 2003 5:38 AM
2.1k
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)