Associative arrays in D and default comparators
Walter Bright
newshound at digitalmars.com
Fri Sep 8 01:49:05 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.
One way to solve this is to have the Thread constructor add a unique
sequence number.
More information about the Digitalmars-d
mailing list