[phobos] Issue with opEquals(Object, Object)

Steve Schveighoffer schveiguy at yahoo.com
Fri Apr 23 19:07:49 PDT 2010


Aside from some of the issues of the new object comparison routine, which has a couple outstanding bugs, I've ran into an interesting issue for dcollections.

For dcollections, I allow opEquals on two like types -- for example, you can call opEquals on two Set types, even if one is a TreeSet and one is a HashSet.

Now, when you compare for example a TreeSet to any other Set type, the TreeSet has enough smarts to do the comparison.  However, the new opEquals is going to run the comparison *twice* when they are equal, once against each set, to see that they both agree.  While this doesn't exactly affect the big-O complexity, it seems unnecessary in the case where I know that running the algorithm once is good enough.

One possibility is for opEquals to have a flag that indicates whether the other side has 'already verified' equality.  That way, I can skip the extra loop if I trust the other type knows what it is doing (e.g. if TreeSet knows the other object is a Set type, and it says we're equal, TreeSet just returns true).

Comments?  Ideas?  I realize this api is in TDPL, I hope we can figure this out.

-Steve


      


More information about the phobos mailing list