Associative arrays in D and default comparators

Walter Bright newshound at digitalmars.com
Fri Sep 8 02:02:06 PDT 2006


Sean Kelly wrote:
> Walter Bright wrote:
>> Can you give an example of a class that could not have a meaningful 
>> opCmp implementation that one would want to put into an AA?
> 
> The one I've been wrestling with is a Thread class, as it has no data 
> that is static and unique for the life of the object.  The thread id is 
> only guaranteed to be unique while the thread is active, and the id 
> isn't even assigned until Thread.start is called.  Threads simply have 
> no features which inherently support ordering, but it makes sense to 
> compare two Thread objects for equality simply by comparing object 
> addresses.

How do you do a hash for it if there's no constant data?



More information about the Digitalmars-d mailing list