bugs? hash and the debugger.
Tim Olson
tim at jumpnet.com
Wed Dec 8 01:48:55 UTC 1999
Yoshiki wrote:
> I think it is not the case of the debugger problem. But
>when you execute the following,
>
>((1 to: 100) select: [:i | s _ Set with: (Set with: 1 with: #a) with: 1.
>s includes: (Set with: 1 with: #a)]) size
>
>the answer is not 100.
Ah, sure enough; it's the hashing problem.
> So, I propose to define Collection>>hash something like:
>----------
>hash
> | hash index |
> hash _ self species hash.
> index _ 0.
> self do: [:item |
> (index _ index + 1) > 3 ifTrue: [^hash].
> hash _ hash bitXor: (((hash bitShift: -6) bitOr: ((hash bitAnd: 16r3F)
>bitShift: 6)) + item hash).
> ].
> ^hash.
>----------
>
> How do you think?
This looks like it corresponds to the implementation of Collection>>=
nicely, and should work for any kind of Collection.
-- tim
More information about the Squeak-dev
mailing list
|