Re: Comparing DS_HASH_TABLE objects

Paul Cohen <[email protected]> Sun, 31 May 2009 22:30:13 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.general
Message-ID <[email protected]>
On Sun, May 31, 2009 at 8:43 PM, Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> wrote:
>> How do I compare two DS_HASH_TABLE objects for object equality?
>
> I don't know what you mean. Do you want to consider two
> hash tables equal if the items they contain are equal?

I am aware that there are different ways of defining equality between
two tables t1 and t2. My assumption was something like:

t1.keys.is_equal (t2.keys) and then
   for each key k1 in t1:
       (t1 @ k1).is_equal (t2 @ k2)

I don't think the 'equality_tester':s should be used since they have
more with how DS_HASH_TABLE:s work, than what they contain (though how
they work will of course affect what they contain!).

> If so, what does it mean for two items in the hash tables
> to be equal? Should they have the same key?

Yes and the items should be 'is_equal'.

> If so, I don't
> think there is a feature for that in DS_HASH_TABLE.
> The implementation of `is_equal' uses '=' to compare
> items.

Yes. I saw that. Why '=' and not 'is_equal'?

I was just asking to make sure I hadn't overlooked anything and to see
if anyone had a standard idiom for this problem.

I'm writing a test case for a situation where a DS_HASH_TABLE [ANY,
UC_STRING] is converted to another representation (JSON object) and
then back again, and I want to check that the two tables are "equal".
Obviously they won't contain the same objects so comparing by
reference isn't of much help. Note that I'm using ANY as the type for
my items.

/Paul

-- 
Paul Cohen
www.seibostudios.se
mobile: +46 730 787 035
e-mail: paul.cohen-qf2BM/[email protected]


------------------------------------

To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected]! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/gobo-eiffel/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/