Hashing

Dana Anthony daanth at unx.sas.com
Thu Apr 16 21:07:25 UTC 1998


Travis Griggs wrote:
> 
> All of this talk about hashing, again. :) A while ago a posted what I
> thought was a nice solution to this whole problem. I got no response on
> it, so I was never sure whether it was deemed a good thing, a weird
> thing (green plane idea), or a bad thing.

I'm still so unclear on the plane color issue that I have no clue.
> 
> The idea was to use the same pattern that SortedCollection uses by
> giving Set a two block instance variables, one a two argument block to
> compare two objects by (equivalenceBlock) and the other a single
> argument block (hashBlock) used to compute the hash value of an object.
> I never toyed with using symbol to send via perform: and perform:with:,
> though that might be faster?

This is the first I have seen of this idea but your explanation makes
sense now that I have read it.  It's true, the Set is like a
Sorted Collection, and these blocks are exactly parallel to the
sort block.  The only reason I can see of not doing it this way
is that sets are used in Smalltalk implementation itself.  But
for that reason they could easily have a distinct Set implementation
that was different with a common superclass. (the way they have
Symbol different from String basically, or CompiledMethod as a
kind of Collection...)

Like SortedCollection, the default should be doing it the way the
object does in its = and hash methods.  So the default blocks
should be:   [ :x :y | x = y ] and [ :x | x hash ].
But you could supply any block you wanted.   Well, I'm all for it.

> 
> --
> Travis Griggs
> Key Technology
> tgriggs at keyww.com

-- 
Dana LG Anthony
Internet Publications Technology at SAS Institute
daanth at unx.sas.com





More information about the Squeak-dev mailing list