Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / hash.h
blob54babcd77ce955e94e4105592357996c60659f9a
1 OBJECT hash_new(STATE);
2 OBJECT hash_new_sized(STATE, int size);
3 void hash_setup(STATE, OBJECT hsh, int size);
4 OBJECT hash_add(STATE, OBJECT h, unsigned int hsh, OBJECT key, OBJECT data);
5 OBJECT hash_set(STATE, OBJECT hash, OBJECT key, OBJECT val);
6 OBJECT hash_get(STATE, OBJECT hash, unsigned int hsh);
7 OBJECT hash_get_undef(STATE, OBJECT hash, unsigned int hsh);
8 OBJECT hash_delete(STATE, OBJECT self, unsigned int hsh);
9 OBJECT hash_s_from_tuple(STATE, OBJECT tup);
10 OBJECT hash_get_undef(STATE, OBJECT hash, unsigned int hsh);
11 OBJECT hash_find_entry(STATE, OBJECT h, unsigned int hsh);
12 OBJECT hash_dup(STATE, OBJECT hsh);
13 void hash_redistribute(STATE, OBJECT hsh);
15 int hash_lookup(STATE, OBJECT tbl, OBJECT key, unsigned int hash, OBJECT *value);
16 int hash_lookup2(STATE, int (*compare)(STATE, OBJECT, OBJECT), OBJECT tbl, OBJECT key, unsigned int hash, OBJECT *value);
17 void hash_assign(STATE, int (*compare)(STATE, OBJECT, OBJECT), OBJECT tbl, OBJECT key, unsigned int hash, OBJECT value);
20 #define hash_find(state, hash, key) (hash_get(state, hash, object_hash_int(state, key)))
22 #define hash_find_undef(state, hash, key) (hash_get_undef(state, hash, object_hash_int(state, key)))
24 #define MAX_DENSITY 0.75
26 /* TODO: fix to determine whether to redistribute both up and down */
27 #define hash_redistribute_p(hash) (N2I(hash_get_entries(hash)) >= MAX_DENSITY * N2I(hash_get_bins(hash)))
29 #define CSM_SIZE 12
31 #define csm_new(st) tuple_new(st, CSM_SIZE)
32 #define csm_size(st, obj) (NUM_FIELDS(obj) / 2)
34 OBJECT csm_find(STATE, OBJECT csm, OBJECT key);
35 OBJECT csm_add(STATE, OBJECT csm, OBJECT key, OBJECT val);
36 OBJECT csm_into_hash(STATE, OBJECT csm);
37 OBJECT csm_into_lookuptable(STATE, OBJECT csm);