On Mar 28, 2010, at 11:11 AM, Thomas Tempelmann wrote:
I believe to have once been explained (by oe Strout, IIRC) that the
Dictionary class uses the object's compare function in order to match
up equal keys. That's, for instance, why Strings, even if they not
point to the same memory "object" (i.e address), are still matched up
as keys in a directory.
Now, I've written a little class that combines two values, and I've
implemented the Operator_Compare function adequately.
However, when I insert or lookup objects of this class in a
Dictionary, Operator_Compare is not invoked, meaning I can not match
up objects containing the same values.
Do I do something wrong or did I misunderstand how Dictionary is
implemened?
The latter -- I reported this issue years ago.
As best as I can tell, the root of the problem is the refusal of RS to
add an actual Object class with virtual methods. This prevents
Operator_Compare (and other such methods) from working as expected
when the declared type of the first argument lacks an Operator_Compare
method. For Dictionary, probably one would need to be able to
override a Hash method so that objects defined to be equal via
Operator_Compare have the same hash.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|