From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2005-06-24 05:59:00
Vladimir Prus <ghost <at> cs.msu.su> writes:
> On Friday 24 June 2005 12:27, JoaquÃn MÂª LÃ³pez MuÃ±oz wrote:
> > The hardest part is checking for equality. My proposal is
> > to follow a hash-based approach, which is effective both in
> > terms of complexity and space (one word per tracked object.),
> > and does not impose any special requirement on the serialized
> > objects (for instance, an approach based on operator== would
> > require that objects be equalitycomparable).
> > What do you think?
> This suggestion is very interesting! But I wonder, how you can detect for
> that objects are the same using a hash. Two different object can hash to the
> same value? Maybe, operator== is still needed?
Admittedly, hash-based checking is not 100% safe, but
I don't think resorting to operator== is doable because:
* A serializable type need not be equality comparable.
* Even if the type is equality comparable, you'd have
to store a copy of the object first time you see it in
order to check it later against later occurrences.
This further imposes assignability on the type, and the
overhead of copying and storing a whole object can be
JoaquÃn M LÃ³pez MuÃ±oz
TelefÃ³nica, InvestigaciÃ³n y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk