Re: Re: suggestions for newbee

Rohan Hart <[email protected]> Mon, 11 Jul 2005 11:55:05 +1200
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
On Thu, 7 Jul 2005, Daniel Bonniot said:
 >> In such a case it would seem preferable to make DeepEquals
 >> "equals" and to define "shallowEquals" where it is needed.

 > The idea was to generate different implementations of equals
 > depending on the interface implemented. Of course using different
 > names is also possible. I'm not really sure if this is important
 > and which style would be most useful, so I'm waiting for feedback.

I'd use the same name for both as that keeps the definition of
equality under the classes control.

 > BTW, would it make sense to handle deep equality with cycles by using some
 > marking (hashtable)?

Yes, probably through a (thread local?) map of the objects
identities.

  <T> Map<T,T> tests;
  equals(a, b) {
    if tests.get(a) == b
      return true;  // ??

    tests.set(a, b);
    // do normal equality checks
  }

Rohan



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar