2 // Closed hash table that does not store the keys
4 // needs the maximum number of elements stored to be declared at creation time
5 // cannot remove elements
6 // does not store the key, rather, it reports all the collisioning values
7 // right value under collisions
8 // CANNOT STORE ZERO in the value
16 { uint size; // # of table entries
17 uint bits; // bits per entry
23 // creates a table to store up to n values with guaranteed load factor.
24 // vbits = # of bits per entry, ENTRIES CANNOT HAVE VALUE ZERO
25 hash createHash (uint n, uint vbits, float factor);
26 // frees the structure
27 void destroyHash (hash H);
29 void insertHash (hash H, uint key, uint elem);
30 // looks for a key, returns first value (zero => no values)
31 // writes in pos a handle to get next values
32 uint searchHash (hash H, uint key, handle *h);
33 // gets following values using handle *h, which is rewritten
34 // returns next value (zero => no more values)
35 uint nextHash (hash H, handle *h);
37 // two large primes found with etc/hash.c
38 #define PRIME1 ((uint)4294967279)
39 #define PRIME2 ((uint)4294967197)