なかだです。
Float#hashが異様に衝突するようです。以下のコードで調べてみると、
有効率は5%程度です。
a = Array.new(10_000) {rand}
h = Hash.new(0)
a.each {|x| h[x.hash] += 1}
p h.size.to_f / a.size.to_f
Index: numeric.c
===================================================================
RCS file: /cvs/ruby/src/ruby/numeric.c,v
retrieving revision 1.101.2.23
diff -p -U 2 -r1.101.2.23 numeric.c
--- numeric.c 1 May 2006 03:46:46 -0000 1.101.2.23
+++ numeric.c 24 Aug 2006 13:57:07 -0000
@@ -871,5 +871,5 @@ flo_hash(num)
c = (char*)&d;
for (hash=0, i=0; i<sizeof(double);i++) {
- hash += c[i] * 971;
+ hash = (hash << 2) ^ (c[i] * 971);
}
if (hash < 0) hash = -hash;
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦