Shouldn't 2 hash = 2.0 hash? [LONG]
Travis Griggs
tgriggs at keyww.com
Tue Nov 30 06:08:24 UTC 1999
"David N. Smith (IBM)" wrote:
> At 17:41 -0500 11/29/99, agree at carltonfields.com wrote:
> >... SNIP ...
> >
> >Just out of curiousity, is there any real reason why Floats with
> >integer truncations shouldn't hash to the same value as their
> >integer counterparts? How much slower would that really be?
>
> Well, on the surface it wouldn't seem too hard:
>
> Float>>hash
> self fractionPart = 0.0 ifTrue: [
> ^ self integerPart asInteger hash ].
> " drop thru to existing code "
>
> I recall that the current Float>>hash was a temporary method anyhow,
> and that I have a better one (larger range) somewhere. Maybe it is
> time to get that back out and see about making this change?
I still think encapsulating the hash function with the target Set via a
block (analagous to SortedCollection's sortBlock) is the way to do this.
It allows the hash function to be customized to the need of the sub
system (performance/efficiency vs. generality).
--
Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
P-P-P-Penguin Power!
More information about the Squeak-dev
mailing list
|