javolution, which is a library with reimagined and heavily optimized
standard collection libraries, includes the notion of providing an
equality and hasher checker, in the same vein as Comparator. (It was
built for ME, so, the optimizations are straight forward, but include
such useful features as lists which don't have the erratic performance
behaviour of ArrayList, because it doesn't transfer new entries into a
new array when you hit capacity limit. It's even BSD-style FOSS. I'm
amazed it doesn't get more love, really).

Regardless of the utility of that, your average bog-standard Point3D
class probably should ship with an equals() method that works. After
all, it's in java.lang.Object, so, unless you want to hack the JVM and
break a few billion existing lines of code, these discussions about
EqualsIn2D and friends are effectively moot.

On Oct 19, 4:15 am, Josh Berry <[email protected]> wrote:
> On Sun, Oct 17, 2010 at 2:06 AM, Reinier Zwitserloot <[email protected]> 
> wrote:
>
> \> But now we're in deep trouble. If [0, 0, 1] is equal to [0, 0], and
>
> > [0, 0] is in turn equal to [0, 0, 2], we are forced by the
> > transitivity rule to conclude that [0, 0, 1] is equal to [0, 0, 2].
> > But that's preposterous! Nobody  would expect these 2 different points
> > in 3D space to nevertheless be .equals() to each other. And yet,
> > that's the ONLY way to get equality right if Point is written with
> > that instanceof check.
>
> I guess this example is why I like the type class approach.  I can
> easily imagine there may be a desire to have an EqualsIn2d<Point>
> checker that does exactly as you said.  Wouldn't even have to be
> "preposterous."
>
> I cede that there is a lot that would have to be rewritten to get this
> equals method in many of the standard collections.  But, I can't
> imagine it would be any worse than having stuff like the
> IdentityHashMap.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to