1 # Requires: Object#hash
4 ivar_as_index :__ivars__ => 0, :keys => 1, :values => 2, :bins => 3, :entries => 4, :default => 5, :default_proc => 6
7 Ruby.primitive :allocate_hash
8 raise PrimitiveFailure, "Hash.allocate primitive failed"
29 @values = Tuple.new(@bins)
33 def set_by_hash(hsh, key, val)
34 Ruby.primitive :hash_set
35 if hsh.kind_of? Integer
36 # This magic value is the fixnum max.
37 return get_by_hash(hsh % 536870911, key)
40 raise PrimitiveFailure, "Hash#set_by_hash failed."
43 def get_by_hash(hsh, key)
44 Ruby.primitive :hash_get
45 if hsh.kind_of? Integer
46 # This magic value is the fixnum max.
47 return get_by_hash(hsh % 536870911, key)
50 raise PrimitiveFailure, "Hash#get_by_hash failed."
54 code, hk, val, nxt = get_by_hash(key.hash, key)
55 return nil unless code
60 set_by_hash key.hash, key, val
64 Ruby.primitive :hash_redistribute
65 raise PrimitiveFailure, "Hash#redistribute failed"
68 def delete_by_hash(hsh, key)
69 Ruby.primitive :hash_delete
70 raise PrimitiveFailure, "Hash#delete_by_hash failed"
75 while i < @values.fields
78 yield tup.at(1), tup.at(2)