Point>>hash is not defined symmetrically over its x and y variables:
^x hash hashMultiply bitXor: y hash
As a result performance of hashed collections containing points shows
very asymmetrical run times:
Time millisecondsToRun:[
d := Dictionary new.
1 to: 3 do:[:x | 1 to: 1000 do: [:y |
d at: x@y put: #foo]].
1 to: 3 do:[:x | 1 to: 1000 do: [:y |
d removeKey: x@y]].
]
"30532 30022 29883"
Time millisecondsToRun:[
d := Dictionary new.
1 to: 3 do:[:y | 1 to: 1000 do: [:x |
d at: x@y put: #foo]].
1 to: 3 do:[:y | 1 to: 1000 do: [:x |
d removeKey: x@y]].
]
"8 8 8"
If I change the implementation of Point>>hash to be symmetric:
^x hash hashMultiply bitXor: y hash hashMultiply
the run times reported are
" 9 10 9 "
and
" 9 10 10"
HTH,
Reinout
--------
_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc